コード例 #1
0
 /// <summary>
 /// Set initial parameters.
 /// </summary>
 public void Init(CWorld World, int PlayerIndex)
 {
     mWorld    = World;
     mPlayerId = PlayerIndex;
     mActive   = false;
     _counter  = 0;
 }
コード例 #2
0
    public override void Init(CWorld World)
    {
        base.Init(World);
        mType = EType.ITEM_SAFE;

        mValue = 10000;
    }
コード例 #3
0
        public override bool CanUseItem(Player player)
        {
            int   num  = 0;
            float num2 = Main.maxTilesX / 4200;
            int   num3 = (int)(400f * num2);

            for (int j = 5; j < Main.maxTilesX - 5; j++)
            {
                int num4 = 5;
                while (num4 < Main.worldSurface)
                {
                    if (Main.tile[j, num4].active() && Main.tile[j, num4].type == (ushort)ModContent.TileType <Tiles.CometOre>())
                    {
                        num++;
                        if (num > num3)
                        {
                            BaseUtility.Chat("Another comet exists in this world in some form or another already...", new Color(136, 151, 255), true);
                            return(false);
                        }
                    }
                    num4++;
                }
            }
            CWorld.DropMeteor();
            return(true);
        }
コード例 #4
0
 public virtual void Init(CWorld World)
 {
     mType   = EType.NONE;
     mOwner  = 0;
     mWorld  = World;
     mActive = true;
 }
コード例 #5
0
ファイル: Workspace.cs プロジェクト: HenningAx/KlaxGameEngine
        private void OnPlayGame(object argument)
        {
            IsInPlayMode = true;
            m_prePlayModeLevelReference = OpenedLevelAsset;

            UndoRedoModel.IsRecording = false;
            UndoRedoModel.Purge(null);

            CViewportViewModel viewport = GetTool <CViewportViewModel>();

            viewport.IsVisible = true;
            viewport.IsActive  = true;
            viewport.LockMouseCursor();

            CEngine.Instance.Dispatch(EEngineUpdatePriority.BeginFrame, () =>
            {
                CWorld world = CEngine.Instance.CurrentWorld;

                m_prePlayModeLevel = new CLevelAsset(world.LoadedLevel, "EditorTempLevel");
                world.StartPlayMode();

                Application.Current.Dispatcher.BeginInvoke(DispatcherPriority.Normal, (Action)(() =>
                {
                }));
            });
        }
コード例 #6
0
        public static void DetachEntityFromAllParents(SEntityId entityId)
        {
            CEngine.Instance.Dispatch(EEngineUpdatePriority.BeginFrame, () =>
            {
                CEntity target = entityId.GetEntity();
                if (target == null || target.RootComponent == null || target.RootComponent.ParentComponent == null)
                {
                    return;
                }

                SEntityComponentId oldRootParent = new SEntityComponentId(target.RootComponent.ParentComponent);

                void Do()
                {
                    CWorld world   = CEngine.Instance.CurrentWorld;
                    CEntity entity = entityId.GetEntity();

                    if (entity != null)
                    {
                        entity.Detach();
                    }
                }

                void Undo()
                {
                    CEngine.Instance.Dispatch(EEngineUpdatePriority.BeginFrame, () =>
                    {
                        CWorld world              = CEngine.Instance.CurrentWorld;
                        CEntity entity            = entityId.GetEntity();
                        CSceneComponent oldParent = oldRootParent.GetComponent <CSceneComponent>();

                        if (oldParent == null)
                        {
                            LogUtility.Log("[UndoRedo] The old parent is invalid! Undo stack has been corrupted and cleared.");
                            UndoRedoUtility.Purge(null);
                            return;
                        }

                        if (entity != null)
                        {
                            entity.AttachToComponent(oldParent);
                        }
                    });
                }

                void Redo()
                {
                    CEngine.Instance.Dispatch(EEngineUpdatePriority.BeginFrame, () =>
                    {
                        Do();
                    });
                }

                Do();

                CRelayUndoItem item = new CRelayUndoItem(Undo, Redo);
                UndoRedoUtility.Record(item);
            });
        }
コード例 #7
0
    public override void Init(CWorld World)
    {
        base.Init(World);
        mType = EType.PICKUP;

        mCarriedByUnitID = -1;
        mBuildTag        = GetNextBuildID();
    }
コード例 #8
0
    public override void Init(CWorld World)
    {
        base.Init(World);
        mType = EType.MISSILE;

        mFiredByUnitID = -1;
        mDead          = -1;
    }
コード例 #9
0
 public override void Init(CWorld world, object userData)
 {
     base.Init(world, userData);
     if (GetComponent <CScenePickingComponent>() == null)
     {
         ScenePickingComponent = AddComponent <CScenePickingComponent>(true, true);
     }
 }
コード例 #10
0
 public CPlayer(CWorld World, int ID)
 {
     _world          = World;
     mID             = ID;
     mAvailableItems = new List <string>();
     mHumanInput     = false;
     mSpawnItemID    = -1;
 }
コード例 #11
0
    public override void Init(CWorld World)
    {
        base.Init(World);
        mType = EType.RESUME;

        mAvailableFor   = 70 * CWorld.TICKS_PER_SECOND;
        mAvailableUntil = mWorld.mGameTick + mAvailableFor;
    }
コード例 #12
0
    /// <summary>
    /// Create an entity and assign ID.
    /// </summary>
    public static T Create <T>(CWorld World, int ID = 0)
        where T : CEntity, new()
    {
        T entity = new T();

        _InitNewEntity(entity, World, ID);

        return(entity);
    }
コード例 #13
0
        public override void Init(CWorld world, object userData)
        {
            base.Init(world, userData);
            m_cameraComponent = AddComponent <CCameraComponent>(true, false);
            m_cameraComponent.RegisterDuringInit = true;
            m_cameraComponent.Init();

            m_updateScope = World.UpdateScheduler.Connect(Update, EUpdatePriority.Editor);
        }
コード例 #14
0
    public override void Init(CWorld World)
    {
        base.Init(World);
        mType = EType.ITEM_START;

        mDoorPosition  = 0.0f;
        _deliveryTimer = 0.0f;
        _waitingTimer  = 0.0f;
    }
コード例 #15
0
    public override void Init(CWorld World)
    {
        base.Init(World);
        mType = EType.ITEM_DOOR;

        mAngle  = 0.0f;
        mOpen   = false;
        mLocked = false;
    }
コード例 #16
0
        public void SetWorld(CWorld world)
        {
            World = world;

            Point upperLeft = new Point();

            upperLeft = PointToScreen(new Point(0, 0));
            CEngine.Instance.Dispatch(EEngineUpdatePriority.BeginFrame, () => { World.ViewManager.ResizeView((float)ActualWidth, (float)ActualHeight, (float)upperLeft.X, (float)upperLeft.Y); });
        }
コード例 #17
0
    public void Init(int PlayerID, CItem Item, CWorld World, bool Blueprint)
    {
        if (PlayerID == -1)
        {
            Debug.LogError("CItemProxy should never have a playerID of -1!");
        }

        mID                   = GetNextID();
        mItemID               = Item.mID;
        mState                = EState.S_VISIBLE;
        mPlayerID             = PlayerID;
        mWorld                = World;
        _item                 = Item;
        mBlueprint            = Blueprint;
        mAsset                = Item.mAsset;
        mDurability           = Item.mDurability;
        mMaxDurability        = Item.mMaxDurability;
        mQueueList            = new List <CQueueToken>();
        mPosition             = Item.mPosition;
        mRotation             = Item.mItemRot;
        mBounds               = Item.mBounds;
        mOwnerID              = Item.mOwner;
        mAssignedPaperStacks  = new List <CContractStack>();
        mPaperStackUpdateTick = 0;
        mAssignedUnitID       = -1;

        mSurfaceColor = mWorld.mMap.mBackgroundColor;
        mBounds       = CItem.CalculateBounds(mPosition, mRotation, mAsset.mWidth, mAsset.mLength);

        if (!mBlueprint)
        {
            ModifyLocalCollisionMap(true);

            if (Item.mType == CEntity.EType.ITEM_DOOR)
            {
                mLocked = true;

                if (mWorld.IsAllied(Item.mOwner, PlayerID))
                {
                    mLocked = ((CItemDoor)Item).mLocked;
                }

                DoorModifyLocalCollisionMap(mLocked);
            }
            else if (Item.mType == CEntity.EType.ITEM_SAFE)
            {
                mValue = ((CItemSafe)Item).mValue;
            }
            else if (Item.mType == CEntity.EType.ITEM_DESK)
            {
                mMaxPaperStackSlots = ((CItemDesk)Item).mMaxPaperStackSlots;
            }
        }

        SetVisible();
        UpdateState(Item);
    }
コード例 #18
0
        public SEntityComponentId SpawnScenePicker_EngineThread(CWorld world)
        {
            CScenePickerEntity scenePicker = world.LoadedLevel.GetEntity <CScenePickerEntity>();

            if (scenePicker == null)
            {
                scenePicker = world.SpawnEntity <CScenePickerEntity>();
            }
            return(new SEntityComponentId(scenePicker.ScenePickingComponent));
        }
コード例 #19
0
 private void WorldLoadedCallback(CWorld world)
 {
     if (InvokeRequired)
     {
         Invoke((Action) delegate { this.ShowWorld(world); });
     }
     else
     {
         ShowWorld(world);
     }
 }
コード例 #20
0
    public override void Init(CWorld World)
    {
        base.Init(World);
        mType    = EType.ITEM;
        mItemRot = 0;

        _playerItemViews  = new CItemProxy[CWorld.MAX_PLAYERS];
        _playerVisibility = 0;
        _placedInWorld    = false;
        mUserUnitID       = -1;
    }
コード例 #21
0
    // 0 = company will not participate
    // Increases by one for every completed contract
    // Decreases by 1 for each failure

    /// <summary>
    /// Standard constructor.
    /// </summary>
    public CClientCompany(CWorld World, string Name, Color Colour, float PaperMul, float DeadlineMul, float StackMul)
    {
        _world            = World;
        mPlayerReputation = new int[CWorld.MAX_PLAYERS];
        mPlayerTier       = new int[CWorld.MAX_PLAYERS];

        mName        = Name;
        mColor       = Colour;
        mPaperMul    = PaperMul;
        mDeadlineMul = DeadlineMul;
        mStackMul    = StackMul;
    }
コード例 #22
0
        public void Init(CWorld gameWorld)
        {
            m_gameWorld = gameWorld;

            for (int i = 0; i < System.Environment.ProcessorCount; i++)
            {
                m_looper.AddThread();
            }
            m_physicSpace = new Space(m_looper);
            m_physicSpace.ForceUpdater.Gravity = new Vector3(0, -9.81f, 0);
            m_physicSpace.TimeStepSettings.TimeStepDuration = PhysicsTimeStepDuration;
            Input.RegisterListener(OnInputEvent);
        }
コード例 #23
0
    /// <summary>
    /// Initiallize an entity created by a factory method.
    /// </summary>
    private static void _InitNewEntity(CEntity Entity, CWorld World, int ID)
    {
        if (ID == 0)
        {
            Entity.mID = GetNextID();
        }
        else
        {
            Entity.mID = ID;
        }

        Entity.Init(World);
    }
コード例 #24
0
    public void StartThread(CWorld World, int PlayerID)
    {
        _world          = World;
        _currentPlayer  = PlayerID;
        mEventBufferIn  = new CThreadEventBuffer();
        mEventBufferOut = new CThreadEventBuffer();

        _timer = new System.Diagnostics.Stopwatch();
        _timer.Start();

        _thread = new Thread(_ThreadStart);
        _thread.Start();
    }
コード例 #25
0
        private void ShowWorld(CWorld world)
        {
            engineWorld = world;

            System.Drawing.Point topLeft  = PointToScreen(new System.Drawing.Point(0, 0));
            CRenderer            renderer = CRenderer.Instance;
            IntPtr handlePtr = Handle;

            renderer.Dispatch(ERendererDispatcherPriority.BeginFrame, () => renderer.Resize(ClientSize.Width, ClientSize.Height, topLeft.X, topLeft.Y, handlePtr));
            CEngine.Instance.Dispatch(EEngineUpdatePriority.BeginFrame, () => { engineWorld.ViewManager.ResizeView(ClientSize.Width, ClientSize.Height, topLeft.X, topLeft.Y); });

            Show();
        }
コード例 #26
0
    private CUnit _GetTaskAcceptingUnit(CWorld World, int PlayerID, int PathingRoomID)
    {
        List <CUnit> units = World.mUnits;

        for (int i = 0; i < units.Count; ++i)
        {
            if (units[i].mOwner == PlayerID && units[i].mCanAcceptTask)
            {
                return(units[i]);
            }
        }

        return(null);
    }
コード例 #27
0
    public void Generate(CWorld World, int Tier, int Level)
    {
        mOwner = 0;

        CTierInfo tier = CGame.AssetManager.mUnitRules.GetTier(Tier);

        if (tier == null)
        {
            Debug.LogError("Requested tier did not exist in resume generation");
            return;
        }

        if (Tier == 1)
        {
            Level = 1;            // (int)(World.SimRnd.GetNextFloat() * );
        }
        if (tier.mMaxLevel != 0 && Level > tier.mMaxLevel)
        {
            Level = tier.mMaxLevel;
        }

        mStats.mName  = CUtility.GenerateRandomName(World.SimRnd);
        mStats.mTier  = tier.mTierIndex;
        mStats.mLevel = Level;

        mStats.mSalary          = tier.mSalary.Get(Level);
        mStats.mIntelligence    = tier.mIntelligence.Get(Level);
        mStats.mMaxStamina      = tier.mMaxStamina.Get(Level);
        mStats.mMaxSpeed        = tier.mMaxSpeed.Get(Level);
        mStats.mHungerRate      = tier.mHungerRate.Get(Level);
        mStats.mMaxHunger       = tier.mMaxHunger.Get(Level);
        mStats.mPaperCapacity   = tier.mPaperCapacity.Get(Level);
        mStats.mAttackDamage    = tier.mAttackDamage.Get(Level);
        mStats.mDefense         = tier.mDefense.Get(Level);
        mStats.mIdleTime        = tier.mIdleTime.Get(Level);
        mStats.mWorkStaminaRate = tier.mWorkStaminaRate.Get(Level);
        mStats.mRequiredXP      = tier.mRequiredXP.Get(Level);
        mStats.mPromotionDemand = 1;

        mStats.mMaxStress          = 100;
        mStats.mRestDesired        = 40;
        mStats.mRestForced         = 20;
        mStats.mEatDesired         = 50;
        mStats.mEatForced          = 80;
        mStats.mStressRecoveryRate = 1;
        mStats.mEatRate            = 10;
        mStats.mAttackSpeed        = 1;
    }
コード例 #28
0
    /// <summary>
    /// Creates entity and assigns ID.
    /// </summary>
    public static CEntity Create(EType Type, CWorld World, int ID = 0)
    {
        CEntity entity = null;

        switch (Type)
        {
        case EType.UNIT: entity = new CUnit(); break;

        case EType.ITEM_START: entity = new CItemStart(); break;

        case EType.ITEM_DECO: entity = new CItemDeco(); break;

        case EType.ITEM_DESK: entity = new CItemDesk(); break;

        case EType.ITEM_SAFE: entity = new CItemSafe(); break;

        case EType.ITEM_REST: entity = new CItemRest(); break;

        case EType.ITEM_FOOD: entity = new CItemFood(); break;

        case EType.ITEM_DOOR: entity = new CItemDoor(); break;

        case EType.RESUME: entity = new CResume(); break;

        case EType.CONTRACT: entity = new CContract(); break;

        case EType.PICKUP: entity = new CPickup(); break;

        case EType.MISSILE: entity = new CMissile(); break;

        case EType.VOLUME: entity = new CVolume(); break;

        case EType.DECAL: entity = new CDecal(); break;
        }

        if (entity != null)
        {
            _InitNewEntity(entity, World, ID);
        }
        else
        {
            Debug.LogError("Entity Factory couldn't create a " + (int)Type + " is");
        }

        return(entity);
    }
コード例 #29
0
        public override void Init(CWorld world, object userData)
        {
            base.Init(world, userData);

            m_bIsAlive       = true;
            m_bIsInitialized = true;

            int count = m_components.Count;

            for (int i = 0; i < count; i++)
            {
                m_components[i].Init();
                m_guidToComponent.Add(m_components[i].ComponentGuid, m_components[i]);
            }

            KlaxScriptObject.Init(this);
        }
コード例 #30
0
        public WorldServer(CWorld config)
        {
            this.ID       = config.ID;
            this.Name     = config.Name;
            this.Channels = new ChannelServer[config.Channels];

            short port = config.Port;

            for (byte id = 0; id < config.Channels; id++)
            {
                this.Channels[id] = new ChannelServer(id, this.ID, this.Name, port);

                port++;
            }

            this.Flag          = config.Flag;
            this.EventMessage  = config.EventMessage;
            this.TickerMessage = config.TickerMessage;
        }