Ejemplo n.º 1
0
        private void Compile(EntityResource res, Trigger trigger)
        {
            var ctrigger = new CTrigger();

            ctrigger.ID = Table["Entity.Trigger", trigger.Name];

            ctrigger.VelocityXLowBound = trigger.VelocityXLowBound;
            ctrigger.VelocityYLowBound = trigger.VelocityYLowBound;

            ctrigger.VelocityXHighBound = trigger.VelocityXHighBound;
            ctrigger.VelocityYHighBound = trigger.VelocityYHighBound;

            ctrigger.AccelerationXLowBound = trigger.AccelerationXLowBound;
            ctrigger.AccelerationYLowBound = trigger.AccelerationYLowBound;

            ctrigger.AccelerationXHighBound = trigger.AccelerationXHighBound;
            ctrigger.AccelerationYHighBound = trigger.AccelerationYHighBound;

            ctrigger.OnGround    = (int)trigger.OnGround;
            ctrigger.OnRoof      = (int)trigger.OnRoof;
            ctrigger.OnLeftWall  = (int)trigger.OnLeftWall;
            ctrigger.OnRightWall = (int)trigger.OnRightWall;
            ctrigger.FaceLeft    = (int)trigger.FaceLeft;
            ctrigger.FaceRight   = (int)trigger.FaceRight;

            ctrigger.AnimationID = res.Animations.FindIndex((Animation a) => a.Name == trigger.Animation);

            Writer.WriteStruct(ctrigger);
        }
Ejemplo n.º 2
0
        private void DownItem(CTrigger cTrigger)
        {
            int LastIndex = triggerlist.IndexOf(cTrigger);

            triggerlist.RemoveAt(LastIndex);
            triggerlist.Insert(LastIndex + 1, cTrigger);
        }
Ejemplo n.º 3
0
    public CFibreReg TriggerUnitDead(CFibre Fibre, int ArgCount)
    {
        if (ArgCount == 2)
        {
            CTrigger trigger = new CTrigger();
            trigger.mType             = ETriggerType.UNIT_DEAD;
            trigger.mInfo             = (int)Fibre.mLocal.mStore[Fibre.mFramePtr + 0].mNumber;
            trigger.mCallbackFuncName = Fibre.mLocal.mStore[Fibre.mFramePtr + 1].mString;
            _triggers.Add(trigger);
        }

        return(null);
    }
Ejemplo n.º 4
0
    public CFibreReg TriggerEntityGone(CFibre Fibre, int ArgCount)
    {
        if (ArgCount == 2)
        {
            CTrigger trigger = new CTrigger();
            trigger.mType             = ETriggerType.ENTITY_GONE;
            trigger.mInfo             = (int)Fibre.mLocal.mStore[Fibre.mFramePtr + 0].mNumber;
            trigger.mCallbackFuncName = Fibre.mLocal.mStore[Fibre.mFramePtr + 1].mString;
            _triggers.Add(trigger);
        }

        return(null);
    }
Ejemplo n.º 5
0
    public void SimTick(int Tick)
    {
        for (int i = 0; i < _triggers.Count; ++i)
        {
            CTrigger trigger = _triggers[i];

            bool execute = false;

            if (trigger.mType == ETriggerType.TICK && trigger.mInfo == Tick)
            {
                execute = true;
            }
            else if (trigger.mType == ETriggerType.ENTITY_GONE && _world.GetEntity <CEntity>(trigger.mInfo) == null)
            {
                execute = true;
            }
            else if (trigger.mType == ETriggerType.UNIT_DEAD)
            {
                CUnit unit = _world.GetEntity <CUnit>(trigger.mInfo);

                if (unit == null || unit.mDead)
                {
                    execute = true;
                }
            }

            if (execute)
            {
                _triggers.RemoveAt(i);
                --i;

                if (trigger.mCallbackFibre != null)
                {
                    _fibreVM.ContinueFibre(trigger.mCallbackFibre);
                }
                else
                {
                    _fibreVM.ExecuteFibre(trigger.mCallbackFuncName);
                }
                // TODO: We can shortcut interop execution here. Don't need to create a whole fibre, just call interop directly.
            }
        }

        _fibreVM.ExecuteFibre("on_tick", new CFibreReg[] { new CFibreReg(Tick), new CFibreReg(Tick * CWorld.SECONDS_PER_TICK) });
    }
Ejemplo n.º 6
0
    public CFibreReg WaitTime(CFibre Fibre, int ArgCount)
    {
        if (ArgCount == 1)
        {
            CTrigger trigger = new CTrigger();
            trigger.mType          = ETriggerType.TICK;
            trigger.mInfo          = (int)Fibre.mLocal.mStore[Fibre.mFramePtr + 0].mNumber + _world.mGameTick;
            trigger.mCallbackFibre = Fibre;
            _triggers.Add(trigger);

            // TODO: Fix this cheap way to indicate that we need to suspend thread.
            CFibreReg reg = new CFibreReg();
            reg.mType = EFibreType.COUNT;
            return(reg);
        }

        return(null);
    }
Ejemplo n.º 7
0
        private void TriggerLoad()
        {
            //트리거 데이터 로드
            for (int i = 0; i < TRIG.Count; i++)
            {
                CTrigger trigger = new CTrigger(this, TRIG[i], true);



                Triggers.Add(trigger);
            }
            for (int i = 0; i < MBRF.Count; i++)
            {
                CTrigger trigger = new CTrigger(this, MBRF[i], false);



                Brifings.Add(trigger);
            }
        }
Ejemplo n.º 8
0
    void OnTriggerExit(Collider other)
    {
        CRoleObject ro = BindObject as CRoleObject;

        if (!ro)
        {
            return;
        }
        CTrigger trigger = other.gameObject.GetComponent <CTrigger>();

        if (!trigger)
        {
            return;
        }
        switch (trigger.Eventtype)
        {
        case CTrigger.EventType.Auto:
        {
            // Global.world.OnCloseLevel(trigger);
        }
        break;
        }
    }
Ejemplo n.º 9
0
        private void ListFliter()
        {
            byte[] playercheck = new byte[27];
            int    iii         = 0;



            foreach (ListBoxItem item in PlayerFliter.SelectedItems)
            {
                int index = int.Parse((string)item.Tag);

                if (index == -1)
                {
                    continue;
                }

                playercheck[iii++] = (byte)index;
            }

            MainListBox.Items.Filter = delegate(object obj)
            {
                CTrigger trig = (CTrigger)obj;

                bool rval = true;
                for (int i = 0; i < iii; i++)
                {
                    if (trig.playerlist[playercheck[i]] == 0)
                    {
                        return(false);
                    }
                }


                string str = "";
                switch (SearchType.SelectedIndex)
                {
                case 0:    //주석
                    str = trig.CommentString;
                    break;

                case 1:    //조건
                    str = trig.ConditionString;
                    break;

                case 2:    //액션
                    str = trig.ActionsString;
                    break;

                case 3:    //모두
                    str = trig.ConditionString + trig.ActionsString;
                    break;
                }


                if (String.IsNullOrEmpty(str))
                {
                    return(false);
                }
                int index = str.IndexOf(searchText, 0);
                if (index == -1)
                {
                    return(false);
                }


                return(rval);
            };
        }
Ejemplo n.º 10
0
        public void Triggerinterpreter(LuaInterface.LuaTable t)
        {
            CTrigger cTrigger = new CTrigger(mapData, IsTrigger);

            if (t["players"] != null)
            {
                LuaInterface.LuaTable players = (LuaInterface.LuaTable)t["players"];
                for (int i = 1; i <= players.Values.Count; i++)
                {
                    double v    = (double)Lua.GetFunction("ParsePlayer").Call(players[i])[0];
                    int    pnum = (int)v;

                    cTrigger.playerlist[pnum] = 1;
                }
            }
            if (t["flag"] != null)
            {
                LuaInterface.LuaTable flags = (LuaInterface.LuaTable)t["flag"];

                ushort flag = 0;
                for (int i = 1; i <= flags.Values.Count; i++)
                {
                    double v     = (double)Lua.GetFunction("ParseTrigFlag").Call(flags[i])[0];
                    int    flagv = (int)v;

                    flag += (ushort)(0b1 << flagv);
                }

                cTrigger.exeflag = flag;
            }
            if (t["conditions"] != null)
            {
                LuaInterface.LuaTable conds = (LuaInterface.LuaTable)t["conditions"];
                for (int i = 1; i <= conds.Values.Count; i++)
                {
                    LuaInterface.LuaTable con = (LuaInterface.LuaTable)conds[i];

                    bool tEnable = true;
                    if (con["Disable"] != null)
                    {
                        con     = (LuaInterface.LuaTable)con["item"];
                        tEnable = false;
                    }

                    TrigItem trigItem = GetTrigItem(con);
                    if (trigItem == null)
                    {
                        continue;
                    }


                    trigItem.IsEnable = tEnable;

                    cTrigger.conditions.Add(trigItem);
                }
            }
            if (t["actions"] != null)
            {
                LuaInterface.LuaTable acts = (LuaInterface.LuaTable)t["actions"];
                for (int i = 1; i <= acts.Values.Count; i++)
                {
                    LuaInterface.LuaTable act = (LuaInterface.LuaTable)acts[i];

                    bool tEnable = true;
                    if (act["Disable"] != null)
                    {
                        act     = (LuaInterface.LuaTable)act["item"];
                        tEnable = false;
                    }

                    TrigItem trigItem = GetTrigItem(act);
                    if (trigItem == null)
                    {
                        continue;
                    }

                    trigItem.IsEnable = tEnable;

                    cTrigger.actions.Add(trigItem);
                }
            }

            Triggers.Add(cTrigger);
        }
Ejemplo n.º 11
0
            public RAWTRIGMBRF(CTrigger cTrigger)
            {
                for (int c = 0; c < 16; c++)
                {
                    RawCondition condition = new RawCondition();


                    if (cTrigger.conditions.Count > c)
                    {
                        TrigItem trigItem = cTrigger.conditions[c];


                        if (trigItem.type == 24)
                        {
                            long offset   = trigItem.args[0].VALUE;
                            long player   = (offset - 0x58A364) / 4;
                            long unitid   = 0;
                            long modifier = trigItem.args[1].VALUE;
                            long value    = trigItem.args[2].VALUE;

                            long mask    = trigItem.args[3].VALUE;
                            long maskuse = trigItem.args[4].VALUE;

                            condition.values[1] = player;
                            condition.values[3] = unitid;
                            condition.values[2] = value;
                            condition.values[4] = modifier;
                            condition.values[0] = mask;
                            condition.values[8] = maskuse;
                            condition.valueSet();
                            condition.condtype = (byte)15;
                        }
                        else
                        {
                            for (int i = 0; i < trigItem.args.Count; i++)
                            {
                                int pos = trigItem.args[i].argDefine.pos;

                                condition.values[pos] = trigItem.args[i].GetCHKValue;
                            }
                            condition.valueSet();
                            condition.condtype = (byte)trigItem.type;
                        }


                        condition.flags = (byte)trigItem.triggerDefine.FLAG;
                        if (!trigItem.IsEnable)
                        {
                            condition.flags += 2;
                        }
                    }

                    conditions[c] = condition;
                }
                for (int a = 0; a < 64; a++)
                {
                    RawAction action = new RawAction();



                    if (cTrigger.actions.Count > a)
                    {
                        TrigItem trigItem = cTrigger.actions[a];


                        if (trigItem.type == 58)
                        {
                            long offset   = trigItem.args[0].VALUE;
                            long player   = (offset - 0x58A364) / 4;
                            long unitid   = 0;
                            long modifier = trigItem.args[1].VALUE;
                            long value    = trigItem.args[2].VALUE;

                            long mask    = trigItem.args[3].VALUE;
                            long maskuse = trigItem.args[4].VALUE;

                            action.values[4]  = player;
                            action.values[6]  = unitid;
                            action.values[5]  = value;
                            action.values[8]  = modifier;
                            action.values[0]  = mask;
                            action.values[10] = maskuse;
                            action.valueSet();
                            action.acttype = (byte)45;
                        }
                        else
                        {
                            for (int i = 0; i < trigItem.args.Count; i++)
                            {
                                int pos = trigItem.args[i].argDefine.pos;

                                action.values[pos] = trigItem.args[i].GetCHKValue;
                            }
                            action.valueSet();
                            action.acttype = (byte)trigItem.type;
                        }

                        action.flags = (byte)trigItem.triggerDefine.FLAG;
                        if (!trigItem.IsEnable)
                        {
                            action.flags += 2;
                        }
                    }

                    actions[a] = action;
                }


                exeflag    = cTrigger.exeflag;
                playerlist = cTrigger.playerlist;
                trigindex  = 0;
            }