public override System.Collections.Generic.Queue <Moonfish.Tags.BlamPointer> ReadFields(System.IO.BinaryReader binaryReader)
 {
     System.Collections.Generic.Queue <Moonfish.Tags.BlamPointer> pointerQueue = new System.Collections.Generic.Queue <Moonfish.Tags.BlamPointer>(base.ReadFields(binaryReader));
     this.TriggerReferencesTriggerFlags = ((TriggerFlags)(binaryReader.ReadInt32()));
     this.Trigger  = binaryReader.ReadShortBlockIndex1();
     this.fieldpad = binaryReader.ReadBytes(2);
     return(pointerQueue);
 }
Пример #2
0
 internal TriggersBlockBase(BinaryReader binaryReader)
 {
     this.name            = binaryReader.ReadString32();
     this.triggerFlags    = (TriggerFlags)binaryReader.ReadInt32();
     this.combinationRule = (CombinationRule)binaryReader.ReadInt16();
     this.invalidName_    = binaryReader.ReadBytes(2);
     this.conditions      = ReadOrderCompletionConditionArray(binaryReader);
 }
 public override System.Collections.Generic.Queue <Moonfish.Tags.BlamPointer> ReadFields(System.IO.BinaryReader binaryReader)
 {
     System.Collections.Generic.Queue <Moonfish.Tags.BlamPointer> pointerQueue = new System.Collections.Generic.Queue <Moonfish.Tags.BlamPointer>(base.ReadFields(binaryReader));
     this.Name = binaryReader.ReadString32();
     this.TriggersTriggerFlags = ((TriggerFlags)(binaryReader.ReadInt32()));
     this.CombinationRule      = ((CombinationRuleEnum)(binaryReader.ReadInt16()));
     this.fieldpad             = binaryReader.ReadBytes(2);
     pointerQueue.Enqueue(binaryReader.ReadBlamPointer(56));
     return(pointerQueue);
 }
Пример #4
0
 /// <summary>
 /// Register a new trigger.
 /// </summary>
 /// <param name="Name">Unique identifier for the trigger.</param>
 /// <param name="Pattern">Regex pattern for the trigger.</param>
 /// <param name="Function">Function that will be called if this trigger fires.</param>
 /// <param name="Flags">Options for the trigger.</param>
 /// <param name="Priority">Lower priority triggers get matched first.</param>
 /// <param name="Arg">Custom argument that will be passed to trigger data.</param>
 protected void RegisterTrigger(string Name, string Pattern, TriggerFunction Function, TriggerFlags Flags, int Priority, int Arg)
 {
     TriggerHandler.RegisterTrigger(Keyword.ToLower().Trim() + "." + Name, Pattern, Function, Flags, Priority, Arg, Keyword.ToLower().Trim());
 }
Пример #5
0
 /// <summary>
 /// Register a new trigger.
 /// </summary>
 /// <param name="Name">Unique identifier for the trigger.</param>
 /// <param name="Pattern">Regex pattern for the trigger.</param>
 /// <param name="Function">Function that will be called if this trigger fires.</param>
 /// <param name="Flags">Options for the trigger.</param>
 /// <param name="Priority">Lower priority triggers get matched first.</param>
 protected void RegisterTrigger(string Name, string Pattern, TriggerFunction Function, TriggerFlags Flags, int Priority)
 {
     RegisterTrigger(Name, Pattern, Function, Flags, Priority, 0);
 }
Пример #6
0
 /// <summary>
 /// Register a new trigger.
 /// </summary>
 /// <param name="Name">Unique identifier for the trigger.</param>
 /// <param name="Pattern">Regex pattern for the trigger.</param>
 /// <param name="Function">Function that will be called if this trigger fires.</param>
 /// <param name="Flags">Options for the trigger.</param>
 protected void RegisterTrigger(string Name, string Pattern, TriggerFunction Function, TriggerFlags Flags)
 {
     RegisterTrigger(Name, Pattern, Function, Flags, 1000);
 }
Пример #7
0
 public TriggersBlock(BinaryReader binaryReader)
 {
     this.name = binaryReader.ReadString32();
     this.triggerFlags = (TriggerFlags)binaryReader.ReadInt32();
     this.combinationRule = (CombinationRule)binaryReader.ReadInt16();
     this.padding = binaryReader.ReadBytes(2);
     {
         var count = binaryReader.ReadInt32();
         var address = binaryReader.ReadInt32();
         var elementSize = Marshal.SizeOf(typeof(OrderCompletionCondition));
         this.conditions = new OrderCompletionCondition[count];
         using (binaryReader.BaseStream.Pin())
         {
             for (int i = 0; i < count; ++i)
             {
                 binaryReader.BaseStream.Position = address + i * elementSize;
                 this.conditions[i] = new OrderCompletionCondition(binaryReader);
             }
         }
     }
 }
Пример #8
0
 public TriggerReferences(BinaryReader binaryReader)
 {
     this.triggerFlags = (TriggerFlags)binaryReader.ReadInt32();
     this.trigger = binaryReader.ReadShortBlockIndex1();
     this.padding = binaryReader.ReadBytes(2);
 }
Пример #9
0
    //Scans and retrieves all the objects in the scene with the environment tag
    private List <ObjectSet> ScanScene()
    {
        List <GameObject> envObjects = GameObjectsInScene();

        List <ObjectSet> mazeSet = new List <ObjectSet>();

        foreach (GameObject env in envObjects)
        {
            //Save the objects transform properties into an ObjectSet

            string envName = env.name;

            if (env.tag == "Spawn")
            {
                if (env.GetComponent <SpawnScript>().playerSpawn)
                {
                    envName += "P";
                }
            }
            //Debug.Log (env);
            int state = 0;
            // For antimatter state determines if it is antimatter or matter. 0 = antimatter, 1 = matter
            if (env.tag == "AntiMatter" && env.GetComponent <AntiMatterScript>().isMatter)
            {
                state = 1;
            }
            else if (env.tag == "EField")
            {
                state = env.GetComponent <ElectricFieldScript>().flips;
                // For Magnetic field state refers to whether or not the magnetic field is into our out of page. 0 = into, 1 = out of
            }
            else if (env.tag == "MField" && env.GetComponent <MagneticFieldScript>().direction)
            {
                state = 1;
                // Whether or not the teleporter is activated, 0 = no, 1 = yes
            }
            else if (env.tag == "Teleporter" && env.GetComponent <TeleporterScript>().enabled)
            {
                state = 1;
                // Whether or not the Measurer is measuring momentem or position. 0 for position, 1 for momentum
            }
            else if (env.tag == "Measurer" && env.GetComponent <MeasurerScript>().pORxMeasure)
            {
                state = 1;
                // Whether or not the spawn is a player spawn or not
            }
            else if (env.tag == "Spawn" && env.GetComponent <SpawnScript>().playerSpawn)
            {
                state = 1;
            }
            else if (env.tag == "Walls")
            {
                //Debug.Log (env.GetComponent<WallScript>());
                // The state is twice the value of the energy in the wall. If the wall is even then the wall is verticle, otherwise it is horizontal
                state = 2 * env.GetComponent <WallScript>().energyConsumption;
                //Debug.Log (env.GetComponent<WallScript>().energyConsumption);
                if (env.GetComponent <WallScript>().IsHorizontal())
                {
                    state++;
                }
                //Debug.Log (state);
            }
            else if (env.tag == "Trigger")
            {
                TriggerPoint triggerScript = env.GetComponent <TriggerPoint>();
                TriggerFlags stateFlag     = 0;
                if (triggerScript.levelEnd)
                {
                    stateFlag |= TriggerFlags.LevelEnd;
                }
                else if (triggerScript.convertMatter)
                {
                    stateFlag |= TriggerFlags.MatterConversion;
                }

                state = ((int)stateFlag);
            }
            else if (env.tag == "Gate" && !env.GetComponent <GateScript>().isMatter)
            {
                state = 1;
            }
            // Determining the state of the object, in terms of rotation or what-not

            /*
             * if(env.tag == dg) {
             *
             *
             * } else {
             *
             * }
             */
            mazeSet.Add(new ObjectSet(env.transform.position, env.transform.rotation, env.transform.localScale, envName, state));
        }

        return(mazeSet);
    }
 internal TriggerReferencesBase(BinaryReader binaryReader)
 {
     this.triggerFlags = (TriggerFlags)binaryReader.ReadInt32();
     this.trigger      = binaryReader.ReadShortBlockIndex1();
     this.invalidName_ = binaryReader.ReadBytes(2);
 }
    // An overloaded create function for level loading, if we already know where the object will be
    public void Create(ObjectSet obj)
    {
        GameObject tempEnv = null;

        if (obj.name.Contains("Barrier"))
        {
            // NOTE, if EVEN then vertical, else horizontal. This implies that the final EVEN energy value is TWICe the total energy
            // Example: Horizontal wall with 100 energy would have a togglestate of 201
            tempEnv = Instantiate(wall, obj.position, obj.rotation) as GameObject;
            tempEnv.transform.localScale = obj.scale;
            if (Mathf.Abs(obj.toggleState) % 2 == 1)                // Absolute value is needed for Antimatter which has negative energy
            {
                obj.toggleState--;
                tempEnv.GetComponent <WallScript>().Flip();
            }
            tempEnv.GetComponent <WallScript>().SetEnergy(obj.toggleState / 2);
        }
        else if (obj.name.Contains("ElectricField"))
        {
            tempEnv = Instantiate(efield, obj.position, Quaternion.identity) as GameObject;            // we use default rotation because we handle flips ourselves
            tempEnv.transform.localScale = obj.scale;
            for (int i = 0; i < obj.toggleState; i++)
            {
                tempEnv.GetComponent <ElectricFieldScript>().Flip();
            }
        }
        else if (obj.name.Contains("Antimatter"))
        {
            tempEnv = Instantiate(antiMatter, obj.position, obj.rotation) as GameObject;
            tempEnv.transform.localScale = obj.scale;
            if (obj.toggleState == 1)
            {
                tempEnv.GetComponent <AntiMatterScript>().Flip();
            }
        }
        else if (obj.name.Contains("ElectricField"))
        {
            tempEnv = Instantiate(efield, obj.position, obj.rotation) as GameObject;
            tempEnv.transform.localScale = obj.scale;
        }
        else if (obj.name.Contains("MagneticField"))
        {
            tempEnv = Instantiate(mfield, obj.position, obj.rotation) as GameObject;
            tempEnv.transform.localScale = obj.scale;
            if (obj.toggleState == 1)
            {
                tempEnv.GetComponent <MagneticFieldScript>().Flip();
            }
        }
        else if (obj.name.Contains("Measurer"))
        {
            tempEnv = Instantiate(measurer, obj.position, obj.rotation) as GameObject;
            tempEnv.transform.localScale = obj.scale;
            if (obj.toggleState == 1)
            {
                tempEnv.GetComponent <MeasurerScript>().Flip();
            }
        }
        else if (obj.name.Contains("SpawnPoint"))
        {
            if (obj.toggleState == 1)
            {
                currentPlayerSpawnPoint.transform.localPosition = obj.position;
            }
            else
            {
                tempEnv = Instantiate(spawnPoint, obj.position, obj.rotation) as GameObject;
                tempEnv.transform.localScale = obj.scale;
            }
        }
        else if (obj.name.Contains("Teleporter"))
        {
            tempEnv = Instantiate(teleporter, obj.position, obj.rotation) as GameObject;
            tempEnv.transform.localScale = obj.scale;
            if (obj.toggleState == 1)
            {
                tempEnv.GetComponent <TeleporterScript>().Flip();
            }
        }
        else if (obj.name.Contains("TriggerPoint"))
        {
            tempEnv = Instantiate(triggerPoint, obj.position, obj.rotation) as GameObject;
            tempEnv.transform.localScale = obj.scale;
            TriggerFlags flags = (TriggerFlags)Mathf.CeilToInt(obj.toggleState);
            if ((flags & TriggerFlags.LevelEnd) != 0)
            {
                tempEnv.GetComponent <TriggerPoint>().SetLevelEnd();
            }
            //if (flags & TriggerFlags.MatterConversion != 0) {
            //	tempEnv.GetComponent<TriggerPoint>().convertMatter = true;
            //}
        }
        else if (obj.name.Contains("Gate"))
        {
            tempEnv = Instantiate(gate, obj.position, obj.rotation) as GameObject;
            tempEnv.transform.localScale = obj.scale;
            if (obj.toggleState == 1)
            {
                tempEnv.GetComponent <GateScript>().Flip();
            }
        }
    }
Пример #12
0
        /// <summary>
        /// Register a new trigger.
        /// </summary>
        /// <param name="Name">Unique identifier for the trigger.</param>
        /// <param name="Pattern">Regex pattern for the trigger.</param>
        /// <param name="Function">Function that will be called if this trigger fires.</param>
        /// <param name="Flags">Options for the trigger.</param>
        /// <param name="Priority">Lower priority triggers get matched first. Default: 1000</param>
        /// <param name="Arg">Custom argument to pass to trigger data.</param>
        /// <param name="Plugin">From which plugin was this registered.</param>
        internal static void RegisterTrigger(string Name, string Pattern, TriggerFunction Function, TriggerFlags Flags, int Priority, int Arg, string Plugin)
        {
            if (string.IsNullOrEmpty(Pattern) || string.IsNullOrEmpty(Name) || Function == null)
            {
                return;
            }

            Name = Name.ToLower().Trim();
            if (Name.Length == 0)
            {
                return;
            }

            Regex p = null;

            if ((Flags & TriggerFlags.NotRegex) == TriggerFlags.None)
            {
                try
                {
                    RegexOptions op = RegexOptions.None;
                    if ((Flags & TriggerFlags.RightToLeft) != TriggerFlags.None)
                    {
                        op |= RegexOptions.RightToLeft;
                    }
                    if ((Flags & TriggerFlags.CaseInsensitive) != TriggerFlags.None)
                    {
                        op |= RegexOptions.IgnoreCase;
                    }
                    p = new Regex(Pattern, op);
                }
                catch
                {
                    return;
                }
            }

            TriggerEntry e = new TriggerEntry();

            e.Function   = Function;
            e.Pattern    = p;
            e.PatternStr = Pattern;
            e.Priority   = Priority;
            e.Name       = Name;
            e.Flags      = Flags;
            e.Arg        = Arg;
            e.Plugin     = Plugin;

            if (TriggersName.ContainsKey(Name))
            {
                Triggers[TriggersName[Name].Priority].Remove(TriggersName[Name]);
            }

            TriggersName[Name] = e;
            if (!Triggers.ContainsKey(e.Priority))
            {
                Triggers[e.Priority] = new List <TriggerEntry>();
            }
            Triggers[e.Priority].Add(e);
        }
Пример #13
0
 /// <summary>
 /// Register a new trigger.
 /// </summary>
 /// <param name="Name">Unique identifier for the trigger.</param>
 /// <param name="Pattern">Regex pattern for the trigger.</param>
 /// <param name="Function">Function that will be called if this trigger fires.</param>
 /// <param name="Flags">Options for the trigger.</param>
 /// <param name="Priority">Lower priority triggers get matched first. Default: 1000</param>
 internal static void RegisterTrigger(string Name, string Pattern, TriggerFunction Function, TriggerFlags Flags, int Priority)
 {
     RegisterTrigger(Name, Pattern, Function, Flags, Priority, 0, "core");
 }
Пример #14
0
 /// <summary>
 /// Register a new trigger.
 /// </summary>
 /// <param name="Name">Unique identifier for the trigger.</param>
 /// <param name="Pattern">Regex pattern for the trigger.</param>
 /// <param name="Function">Function that will be called if this trigger fires.</param>
 /// <param name="Flags">Options for the trigger.</param>
 internal static void RegisterTrigger(string Name, string Pattern, TriggerFunction Function, TriggerFlags Flags)
 {
     RegisterTrigger(Name, Pattern, Function, Flags, 1000);
 }