MCPcopy Create free account
hub / github.com/StrongPC123/Far-Cry-1-Source-Full / SetEventsTable

Method SetEventsTable

Editor/Objects/EntityScript.cpp:713–783  ·  view source on GitHub ↗

/////////////////////////////////////////////////////////////////////

Source from the content-addressed store, hash-verified

711
712//////////////////////////////////////////////////////////////////////////
713void CEntityScript::SetEventsTable( CEntity *entity )
714{
715 if (!IsValid())
716 return;
717 assert( entity != 0 );
718
719 IEntity *ientity = entity->GetIEntity();
720 if (!ientity)
721 return;
722
723 IScriptObject *scriptObject = ientity->GetScriptObject();
724 if (!scriptObject)
725 return;
726
727 // If events target table is null, set event table to null either.
728 if (entity->GetEventTargetCount() == 0)
729 {
730 if (m_haveEventsTable)
731 {
732 scriptObject->SetToNull( "Events" );
733 }
734 m_haveEventsTable = false;
735 return;
736 }
737
738 IScriptSystem *scriptSystem = GetIEditor()->GetSystem()->GetIScriptSystem();
739 _SmartScriptObject pEvents( scriptSystem,false );
740
741 scriptObject->SetValue( "Events",*pEvents );
742 m_haveEventsTable = true;
743
744 std::set<CString> sourceEvents;
745 for (int i = 0; i < entity->GetEventTargetCount(); i++)
746 {
747 CEntityEventTarget &et = entity->GetEventTarget(i);
748 sourceEvents.insert( et.sourceEvent );
749 }
750 for (std::set<CString>::iterator it = sourceEvents.begin(); it != sourceEvents.end(); it++)
751 {
752 _SmartScriptObject pTrgEvents( scriptSystem,false );
753 CString sourceEvent = *it;
754
755 //int srcEventId = EventNameToId( sourceEvent );
756 //pEvents->SetAt( srcEventId,*pTrgEvents );
757 pEvents->SetValue( sourceEvent,*pTrgEvents );
758
759 // Put target events to table.
760 int trgEventIndex = 1;
761 for (int i = 0; i < entity->GetEventTargetCount(); i++)
762 {
763 CEntityEventTarget &et = entity->GetEventTarget(i);
764 if (stricmp(et.sourceEvent,sourceEvent) == 0)
765 {
766 int entityId = 0;
767 if (et.target)
768 {
769 if (et.target->IsKindOf( RUNTIME_CLASS(CEntity) ))
770 entityId = ((CEntity*)et.target)->GetEntityId();

Callers 8

OnBnAddMissionMethod · 0.80
OnPickMethod · 0.80
OnRclickEventTreeMethod · 0.80
SpawnEntityMethod · 0.80
OnEventMethod · 0.80
ResolveEventTargetMethod · 0.80
AddEventTargetMethod · 0.80
RemoveEventTargetMethod · 0.80

Calls 11

GetIEditorFunction · 0.85
SetToNullMethod · 0.80
SetAtMethod · 0.80
stricmpFunction · 0.50
GetScriptObjectMethod · 0.45
GetIScriptSystemMethod · 0.45
GetSystemMethod · 0.45
SetValueMethod · 0.45
insertMethod · 0.45
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected