public bool GetTriggerState(string triggerName, out WorldTriggerState worldTriggerState) { worldTriggerState = null; for (int i = 0; i < Triggers.Count; i++) { WorldTrigger trigger = Triggers [i]; if (trigger.BaseState.Name.Equals(triggerName)) { worldTriggerState = trigger.BaseState; break; } } return(worldTriggerState != null); }
public void AddTrigger(KeyValuePair <string, KeyValuePair <string, string> > triggerStatePair, Transform triggerParentTransform, bool addToTriggerStates, bool useLocalTransform) { string triggerName = triggerStatePair.Key; string triggerScriptName = triggerStatePair.Value.Key; string triggerState = triggerStatePair.Value.Value; GameObject newTriggerObject = triggerParentTransform.gameObject.FindOrCreateChild(triggerName).gameObject; Debug.Log("Trying to add component of type Frontiers.World." + triggerScriptName); //WorldTrigger worldTriggerScript = UnityEngineInternal.APIUpdaterRuntimeServices.AddComponent (newTriggerObject, "Assets/Scripts/GameWorld/WorldChunk.cs (799,38)", triggerScriptName) as WorldTrigger; WorldTrigger worldTriggerScript = newTriggerObject.GetOrAdd(Type.GetType("Frontiers.World." + triggerScriptName)) as WorldTrigger; worldTriggerScript.UpdateTriggerState(triggerState, this, useLocalTransform); newTriggerObject.transform.parent = Transforms.Triggers; //this will update its local transform so the next time it loads it'll be in the right spot worldTriggerScript.RefreshTransform(); Triggers.SafeAdd(worldTriggerScript); }