public void Copy(BehaviourObject _object) { if (_object == null) { return; } base.Copy(_object); BehaviourModes.Clear(); foreach (BehaviourModeObject _mode in _object.BehaviourModes) { BehaviourModes.Add(new BehaviourModeObject(_mode)); } }
/// <summary> /// Saves the behaviour to file. /// </summary> /// <param name="status">Status.</param> public static void SaveBehaviourToFile(BehaviourObject behaviour, string owner) { path = UnityEditor.EditorUtility.SaveFilePanelInProject("Save Behaviour File As", owner.ToLower() + ".cc_behaviours", "cc_behaviours", ""); if (path.Length == 0) { return; } XmlSerializer serializer = new XmlSerializer(typeof(BehaviourObject)); FileStream stream = new FileStream(path, FileMode.Create); serializer.Serialize(stream, behaviour); stream.Close(); }
/// <summary> /// Loads the behaviour from file. /// </summary> /// <returns>The behaviour from file.</returns> /// <param name="behaviour">Behaviour.</param> public static BehaviourObject LoadBehaviourFromFile(BehaviourObject behaviour) { path = UnityEditor.EditorUtility.OpenFilePanel("Open Behaviour File", Application.dataPath, "cc_behaviours"); if (path.Length == 0) { return(behaviour); } XmlSerializer serializer = new XmlSerializer(typeof(BehaviourObject)); FileStream stream = new FileStream(path, FileMode.Open); behaviour = serializer.Deserialize(stream) as BehaviourObject; stream.Close(); return(behaviour); }
public override void Reset() { if (Application.isPlaying) { //Debug.Log( "Creature.Reset: " + OwnerName ); Status.Reset(); Behaviour.Reset(); Move.Reset(); m_ActiveTarget = null; Essentials.Target.Reset(); Missions.Outpost.Target.Reset(); Missions.Escort.Target.Reset(); if (Missions.Patrol.Target != null) { Missions.Patrol.Target.Reset(); } // PREDECISIONS INTERACTORS foreach (InteractorObject _interactor in Interaction.Interactors) { _interactor.Reset(); foreach (TargetObject _target in _interactor.PreparedTargets) { _target.Reset(); } } } else { m_Interaction = new InteractionObject(OwnerComponent); m_Essentials = new EssentialsObject(OwnerComponent); m_Status = new StatusObject(OwnerComponent); m_Behaviour = new BehaviourObject(OwnerComponent); m_Missions = new MissionsObject(OwnerComponent); m_Move = new MoveObject(OwnerComponent); m_Environment = new EnvironmentObject(OwnerComponent); } }
public BehaviourObject(BehaviourObject _object) : base(_object) { Copy(_object); }