static MegaloScriptModelObject CreateForWriteSansId(MegaloScriptModel model, MegaloScriptModelObjectType type) { switch (type) { case MegaloScriptModelObjectType.Condition: return(model.CreateCondition()); case MegaloScriptModelObjectType.Action: return(model.CreateAction()); case MegaloScriptModelObjectType.Trigger: return(model.CreateTrigger()); case MegaloScriptModelObjectType.VirtualTrigger: return(model.CreateVirtualTrigger()); default: throw new KSoft.Debug.UnreachableException(type.ToString()); } }
public override void Serialize(MegaloScriptModel model, IO.BitStream s) { MegaloScriptVirtualTrigger trigger; if (s.IsReading) { trigger = model.CreateVirtualTrigger(); mVirtualTriggerHandle = trigger.Handle; } else { trigger = model.VirtualTriggers[VirtualTriggerHandle.Id]; } trigger.Serialize(model, s); }
/// <summary>Create the identiy of an existing object based on an its handle</summary> /// <param name="model"></param> /// <param name="handle"></param> /// <returns></returns> /// <remarks>Not all object types support this operation</remarks> static MegaloScriptModelObject Recreate(MegaloScriptModel model, MegaloScriptModelObjectHandle handle) { int id = handle.Id; switch (handle.Type) { case MegaloScriptModelObjectType.Condition: return(model.CreateCondition(id)); case MegaloScriptModelObjectType.Action: return(model.CreateAction(id)); case MegaloScriptModelObjectType.Trigger: return(model.CreateTrigger(id)); case MegaloScriptModelObjectType.VirtualTrigger: return(model.CreateVirtualTrigger(id)); default: throw new KSoft.Debug.UnreachableException(handle.Type.ToString()); } }