public void Destroy()
    {
        mState = EState.S_DESTROYED;

        if (!mBlueprint)
        {
            ModifyLocalCollisionMap(false);

            if (mAsset.mItemType == EItemType.DESK)
            {
                if (mAssignedUnitID != -1)
                {
                    CUnit unit = mWorld.GetEntity <CUnit>(mAssignedUnitID);
                    if (unit != null)
                    {
                        unit.mAssignedDeskID = -1;
                    }
                }
            }
            else if (mAsset.mItemType == EItemType.DOOR)
            {
                DoorModifyLocalCollisionMap(false);
            }

            KillQueue();
        }
    }
示例#2
0
    private int _GetTotalInterns(bool IncludeWaitingToSpawn)
    {
        int count = 0;

        for (int i = 0; i < mWorld.mUnits.Count; ++i)
        {
            CUnit unit = mWorld.mUnits[i];
            if (unit.mOwner == mPlayerId && unit.mIntern)
            {
                ++count;
            }
        }

        if (IncludeWaitingToSpawn)
        {
            CItemStart itemStart = mWorld.GetEntity <CItemStart>(mWorld.mPlayers[mPlayerId].mSpawnItemID);

            if (itemStart != null)
            {
                for (int i = 0; i < itemStart.mEvents.Count; ++i)
                {
                    if (itemStart.mEvents[i].mType == CElevatorEvent.EType.T_SPAWN_UNIT)
                    {
                        if (itemStart.mEvents[i].mInfo2 == 0)
                        {
                            ++count;
                        }
                    }
                }
            }
        }

        return(count);
    }
示例#3
0
    /// <summary>
    /// Called when the player cancels this order.
    /// </summary>
    public void OnCancelled()
    {
        CUnit builder = mWorld.GetEntity <CUnit>(mBuilderID);

        if (builder != null)
        {
            builder.AbandonOrder();
        }

        mState           = EState.CANCELLED;
        mBuilderID       = -1;
        mItemBlueprintID = -1;

        mWorld.RemoveBuildOrder(this);
    }
    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) });
    }
示例#5
0
 public CItemStart GetSpawnItem()
 {
     return(_world.GetEntity <CItemStart>(mSpawnItemID));
 }