Exemplo n.º 1
0
 public void Initialize(EntityRegistry registry, EventSystem eventSystem)
 {
     mPostProcessList = new List <Entity>(registry.Capacity);
     registry.SetupSlice(ref mRectNoShape);
     registry.SetupSlice(ref mNoRect);
     registry.SetupSlice(ref mHasRect);
 }
Exemplo n.º 2
0
        private void UpdateControlState(EntityRegistry registry)
        {
            int count = mPlayersSlice.Player.Count;

            for (int i = 0; i < count; ++i)
            {
                int          playerIndex = mPlayersSlice.Player[i].Index;
                GamePadState state       = GamePad.GetState(playerIndex);

                FrogControlState controlState = new FrogControlState();
                controlState.JumpSignal         = state.IsButtonDown(Buttons.A);
                controlState.ToungueSignalState = state.IsButtonDown(Buttons.X);
                Vector2 direction    = state.ThumbSticks.Left;
                float   rawMagnitude = direction.Length();
                if (rawMagnitude >= kMinMagnitude)
                {
                    direction.Normalize();
                }
                else
                {
                    direction = Vector2.Zero;
                }
                controlState.InputDirection = direction;

                Entity controlledFrog = mPlayersSlice.ControlledEntity[i].Entity;
                registry.SetComponent(controlledFrog, controlState);
            }
        }
Exemplo n.º 3
0
        public void Update(EntityRegistry registry, EventSystem eventSystem)
        {
            mDevice.Clear(Color.SkyBlue);

            const float kCharachterDepth = 10f;
            int         frogCount        = mFrogRectSlice.Rect.Count;

            for (int i = 0; i < frogCount; ++i)
            {
                mFrogRenderer.PushFrog(mFrogRectSlice.Rect[i], kCharachterDepth, mFrogRectSlice.Animation[i]);
            }
            mFrogRenderer.Render(mCameraMatrix, mDevice);

            RenderLilies();
            int rectCount = mColoredRectSlice.Rect.Count;

            for (int i = 0; i < rectCount; ++i)
            {
                mRenderer.PushRect(mColoredRectSlice.Rect[i], kCharachterDepth, mColoredRectSlice.Color[i]);
            }
            RenderLetterBox();
            RenderUI();
            RenderWaterBackground();
            mRenderer.RenderAndFlush(mDevice, mBasicEffect);

            RenderWater();
        }
        public void Update(EntityRegistry registry, EventSystem eventSystem)
        {
            int count = mTounguesWithPosition.Entity.Count;

            for (int i = 0; i < count; ++i)
            {
                Entity parentFrog = mTounguesWithPosition.ParentFrog[i].Parent;
                //TODO: The following could be done with a frog slice if there was a clean way to fetch random entities from the slice. Entity output could do that.
                Debug.Assert(registry.IsValid(parentFrog));
                Debug.Assert(registry.HasComponent <Facing>(parentFrog));
                Debug.Assert(registry.HasComponent <Rect>(parentFrog));
                Rect    frogRect = registry.GetComponent <Rect>(parentFrog);
                int     facing   = registry.GetComponent <Facing>(parentFrog).CurrentFacing;
                Vector2 extendDirection;
                Vector2 anchor;
                if (facing >= 0f)
                {
                    extendDirection = Vector2.UnitX;
                    anchor          = frogRect.MaxCorner;
                }
                else
                {
                    extendDirection = -Vector2.UnitX;
                    anchor          = frogRect.MinMaxCorner;
                }
                RectShape toungueShape = mTounguesWithPosition.CurrentShape[i];
                anchor -= (toungueShape.Height * mShapeData.RelativeVerticalOffset * Vector2.UnitY);
                anchor += toungueShape.Width * extendDirection * 0.5f;
                Entity toungueEntity = mTounguesWithPosition.Entity[i];
                registry.SetComponent <Position>(toungueEntity, new Position(anchor));
            }
        }
        private void SetAnimationFrame(EntityRegistry registry, Entity entity, int frameIndex)
        {
            float minX = frameIndex * mFrameWidth;
            float maxX = minX + mFrameWidth;

            registry.SetComponent(entity, new AnimationState(minX, maxX));
        }
 public void Update(EntityRegistry registry, EventSystem eventSystem)
 {
     SetAnimationFrames(registry, mLandedFrog.Entity, mData.LandedFrame);
     SetAnimationFrames(registry, mJumpingFrogSlice.Entity, mData.JumpingFrame);
     UpdateSwimAnimation(registry);
     UpdateFacing(registry);
 }
Exemplo n.º 7
0
        private void CheckOutOfBoundsFlies(EntityRegistry registry)
        {
            int waitingCount = mWaitingToChange.Entity.Count;

            for (int i = waitingCount - 1; i >= 0; --i)
            {
                bool flyingLow   = mWaitingToChange.Position[i].Value.Y < (mFlyData.MinHeight + mPond.WaterLevel);
                bool forceChange = flyingLow || (mWaitingToChange.Position[i].Value.Y > (mFlyData.MaxHeight + mPond.WaterLevel));
                if (forceChange)
                {
                    Vector2 velocity = mWaitingToChange.Velocity[i].Value;
                    float   angle    = mChangeData.TurnAroundRate * mTime.DeltaTime;
                    if ((velocity.X < 0) && flyingLow)
                    {
                        angle = -angle;
                    }
                    else if ((velocity.X > 0) && !flyingLow)
                    {
                        angle = -angle;
                    }
                    Vector2 newVelocity = MathExtensions.Rotate(velocity, angle);
                    registry.SetComponent(mWaitingToChange.Entity[i], new Velocity(newVelocity));
                }
            }
        }
Exemplo n.º 8
0
        public void Update(EntityRegistry registry, EventSystem eventSystem)
        {
            mDevice.Clear(Color.DimGray);

            RenderLilies();

            int frogCount = mFrogRectSlice.Rect.Count;

            for (int i = 0; i < frogCount; ++i)
            {
                mFrogRenderer.PushFrog(mFrogRectSlice.Rect[i], mFrogRectSlice.Animation[i]);
            }
            mFrogRenderer.Render(mCameraMatrix, mDevice);

            int rectCount = mColoredRectSlice.Rect.Count;

            for (int i = 0; i < rectCount; ++i)
            {
                mRenderer.PushRect(mColoredRectSlice.Rect[i], mColoredRectSlice.Color[i]);
            }

            RenderWater();

            mRenderer.Render(mCameraMatrix, mDevice);

            RenderUI();
        }
Exemplo n.º 9
0
        public void Update(EntityRegistry registry, EventSystem eventSystem)
        {
            for (int i = mRectNoShape.Entities.Count - 1; i >= 0; --i)
            {
                registry.RemoveComponent <Rect>(mRectNoShape.Entities[i]);
            }

            int noRectCount = mNoRect.Entities.Count;

            for (int i = 0; i < noRectCount; ++i)
            {
                mPostProcessList.Add(mNoRect.Entities[i]);
            }
            foreach (Entity entity in mPostProcessList)
            {
                registry.AddComponent(entity, new Rect());  //The right data will be updated by the next slice
            }
            mPostProcessList.Clear();

            int hasRectCount = mHasRect.Entities.Count;

            for (int i = 0; i < hasRectCount; ++i)
            {
                Vector2   position  = mHasRect.Position[i].Value;
                RectShape rectShape = mHasRect.RectShape[i];
                Rect      rect      = new Rect(position, rectShape.Width, rectShape.Height);
                registry.SetComponent(mHasRect.Entities[i], rect);
            }
        }
Exemplo n.º 10
0
 public void Update(EntityRegistry registry, EventSystem eventSystem)
 {
     UpdateControlState(registry);
     UpdateNoToungueFrogs(registry);
     UpdateLandedFrogs(registry);
     UpdateSwimingFrogs(registry);
 }
Exemplo n.º 11
0
 public void Initialize(EntityRegistry registry, EventSystem eventSystem)
 {
     registry.SetupSlice(ref mPlayersSlice);
     registry.SetupSlice(ref mLandedFrogs);
     registry.SetupSlice(ref mNoToungueFrogs);
     registry.SetupSlice(ref mWaterborneFrogs);
 }
Exemplo n.º 12
0
        private void UpdateSwimingFrogs(EntityRegistry registry)
        {
            int count = mWaterborneFrogs.Frogs.Count;

            for (int i = 0; i < count; ++i)
            {
                float swimKickPhase = mWaterborneFrogs.Waterborne[i].SwimKickPhase;
                if (swimKickPhase < 0f)
                {
                    swimKickPhase = swimKickPhase + mTime.DeltaTime;
                    if (swimKickPhase >= 0f)
                    {
                        swimKickPhase = mSwimData.SwimKickDuration;
                    }
                }
                else if ((swimKickPhase > 0f) && (mWaterborneFrogs.ControlState[i].InputDirection != Vector2.Zero))
                {
                    swimKickPhase = Math.Max(0f, swimKickPhase - mTime.DeltaTime);
                }
                else if ((swimKickPhase != mSwimData.SwimKickDuration) && (mWaterborneFrogs.ControlState[i].InputDirection == Vector2.Zero))
                {
                    swimKickPhase = -mSwimData.SwimKickRecharge;
                }
                //TODO: Worth to validate the data changed?
                Waterborne waterBorne = new Waterborne(swimKickPhase);
                registry.SetComponent(mWaterborneFrogs.Frogs[i], waterBorne);
            }
        }
Exemplo n.º 13
0
        public void Update(EntityRegistry registry, EventSystem eventSystem)
        {
            int noScoreCount = mNoScoreSlice.Entity.Count;

            for (int i = noScoreCount - 1; i >= 0; --i)
            {
                registry.AddComponent(mNoScoreSlice.Entity[i], new Score());
            }

            if (mScoreBuffer.Count > 0)
            {
                int playerCount = mScoreSlice.Entity.Count;
                for (int i = 0; i < playerCount; ++i)
                {
                    int    currentScore   = mScoreSlice.Score[i].Value;
                    Entity controlledFrog = mScoreSlice.ControlledEntity[i].Entity;
                    foreach (Entity frog in mScoreBuffer)
                    {
                        if (frog == controlledFrog)
                        {
                            ++currentScore;
                        }
                    }
                    registry.SetComponent(mScoreSlice.Entity[i], new Score(currentScore));
                }
                mScoreBuffer.Clear();
            }
        }
Exemplo n.º 14
0
 public void Initialize(EntityRegistry registry, EventSystem eventSystem)
 {
     registry.SetupSlice(ref mLandedFrog);
     registry.SetupSlice(ref mJumpingFrogSlice);
     registry.SetupSlice(ref mSwimingFrogSlice);
     registry.SetupSlice(ref mFacingSlice);
 }
Exemplo n.º 15
0
        private void SetAnimationFrames(EntityRegistry registry, SliceEntityOutput entities, int frameIndex)
        {
            int count = entities.Count;

            for (int i = 0; i < count; ++i)
            {
                SetAnimationFrame(registry, entities[i], frameIndex);
            }
        }
Exemplo n.º 16
0
        public void ReSendUsersLoaded(UsersLoadedEvent e, SingleNode <ClientSessionComponent> session)
        {
            EntityRegistry entityRegistry = Flow.Current.EntityRegistry;

            if (entityRegistry.ContainsEntity(e.RequestEntityId))
            {
                base.ScheduleEvent <UsersLoadedInternalEvent>(entityRegistry.GetEntity(e.RequestEntityId));
            }
        }
        private Vector2 UpdateFrogSwimAndGetAcceleration(EntityRegistry registry, int iterationIndex)
        {
            Vector2 swimAcceleration = Vector2.Zero;

            if (mWetFrogs.Waterborne[iterationIndex].SwimKickPhase > 0f)
            {
                swimAcceleration = mSwimData.SwimAccelerationModule * mWetFrogs.Control[iterationIndex].InputDirection;
            }
            return(swimAcceleration);
        }
Exemplo n.º 18
0
        public void TestComponents()
        {
            EntityRegistry registry = new EntityRegistry(100);

            Entity entity1 = registry.Create();
            Entity entity2 = registry.Create();

            PositionComponent pos1 = new PositionComponent(1, 0);
            PositionComponent pos2 = new PositionComponent(0, 1);

            registry.AddComponent(entity1, new TagComponent());

            registry.AddComponent(entity1, pos1);
            registry.AddComponent(entity2, pos2);

            registry.AddComponent(entity2, new ParentedComponent(entity1));

            Assert.IsTrue(registry.HasComponent <TagComponent>(entity1));
            Assert.IsFalse(registry.HasComponent <TagComponent>(entity2));
            Assert.IsTrue(registry.HasComponent <PositionComponent>(entity1));
            Assert.IsTrue(registry.HasComponent <PositionComponent>(entity2));
            Assert.IsFalse(registry.HasComponent <ParentedComponent>(entity1));
            Assert.IsTrue(registry.HasComponent <ParentedComponent>(entity2));

            Assert.AreEqual(registry.GetComponent <PositionComponent>(entity1), pos1);
            Assert.AreEqual(registry.GetComponent <PositionComponent>(entity2), pos2);

            registry.Destroy(entity1);

            Assert.AreEqual(registry.GetComponent <PositionComponent>(entity2)
                            , pos2);

            Assert.IsFalse(registry.IsValid(registry.GetComponent <ParentedComponent>(entity2).Parent));

            Assert.IsFalse(registry.HasComponent <TagComponent>(entity2));
            Assert.IsTrue(registry.HasComponent <PositionComponent>(entity2));
            Assert.IsTrue(registry.HasComponent <ParentedComponent>(entity2));

            Entity entity3 = registry.Create();
            Entity entity4 = registry.Create();

            registry.AddComponent(entity4, pos1);
            registry.AddComponent(entity3, pos1);
            registry.AddComponent(entity3, new ParentedComponent());
            registry.AddComponent(entity4, new ParentedComponent());
            Assert.IsFalse(registry.HasComponent <TagComponent>(entity3));
            Assert.IsTrue(registry.HasComponent <PositionComponent>(entity3));
            Assert.IsTrue(registry.HasComponent <PositionComponent>(entity4));
            Assert.IsTrue(registry.HasComponent <ParentedComponent>(entity3));
            Assert.IsTrue(registry.HasComponent <ParentedComponent>(entity4));

            Assert.IsFalse(registry.HasComponent <TagComponent>(entity2));
            Assert.IsTrue(registry.HasComponent <PositionComponent>(entity2));
            Assert.IsTrue(registry.HasComponent <ParentedComponent>(entity2));
        }
Exemplo n.º 19
0
        public virtual NbtCompound writeToNbt(NbtCompound tag)
        {
            tag.Add(new NbtInt("id", EntityRegistry.getIdFromEntity(this)));

            tag.Add(NbtHelper.writeVector3("position", this.transform.position));
            tag.Add(NbtHelper.writeVector3("rotation", this.transform.eulerAngles));
            tag.Add(NbtHelper.writeVector3("velocity", this.rBody.velocity));
            tag.Add(NbtHelper.writeVector3("angularVelocity", this.rBody.angularVelocity));

            return(tag);
        }
Exemplo n.º 20
0
        private void UpdateControlState(EntityRegistry registry)
        {
            int count = mPlayersSlice.Player.Count;

            for (int i = 0; i < count; ++i)
            {
                int              playerIndex  = mPlayersSlice.Player[i].Index;
                GamePadState     state        = GamePad.GetState(playerIndex);
                FrogControlState controlState = new FrogControlState();
                Vector2          direction    = Vector2.Zero;
                if (state.IsConnected)
                {
                    controlState.JumpSignal         = state.IsButtonDown(Buttons.A);
                    controlState.ToungueSignalState = state.IsButtonDown(Buttons.X);
                    direction = state.ThumbSticks.Left;
                }
                else
                {
                    KeyboardState keyboardState = Keyboard.GetState();
                    if (keyboardState.IsKeyDown(Keys.Left))
                    {
                        direction.X -= 1.0f;
                    }
                    if (keyboardState.IsKeyDown(Keys.Right))
                    {
                        direction.X += 1.0f;
                    }
                    if (keyboardState.IsKeyDown(Keys.Down))
                    {
                        direction.Y -= 1.0f;
                    }
                    if (keyboardState.IsKeyDown(Keys.Up))
                    {
                        direction.Y += 1.0f;
                    }
                    controlState.JumpSignal         = keyboardState.IsKeyDown(Keys.LeftControl);
                    controlState.ToungueSignalState = keyboardState.IsKeyDown(Keys.Space);
                }
                float rawMagnitude = direction.Length();
                if (rawMagnitude >= kMinMagnitude)
                {
                    direction.Normalize();
                }
                else
                {
                    direction = Vector2.Zero;
                }
                controlState.InputDirection = direction;

                Entity controlledFrog = mPlayersSlice.ControlledEntity[i].Entity;
                registry.SetComponent(controlledFrog, controlState);
            }
        }
        public void Update(EntityRegistry registry, EventSystem eventSystem)
        {
            int hasRectCount = mHasParentedRect.Entities.Count;

            for (int i = 0; i < hasRectCount; ++i)
            {
                Vector2   position  = mHasParentedRect.Position[i].Value;
                RectShape rectShape = mHasParentedRect.RectShape[i];
                Rect      rect      = new Rect(position, rectShape.Width, rectShape.Height);
                registry.SetComponent(mHasParentedRect.Entities[i], rect);
            }
        }
Exemplo n.º 22
0
    public Registry()
    {
        ScriptLoader.LoadScript("Entity", "Entity.lua");
        ScriptLoader.AddCategory("Generator");

        partRegistry   = new PartRegistry();
        entityRegistry = new EntityRegistry();

        namesRegistry = new NameRegistry();

        generator = new Generator();
    }
Exemplo n.º 23
0
        public void TestEntityCreationAndDestruction()
        {
            const int      kEntitiesToTest = 1000;
            int            tests           = 100;
            EntityRegistry registry        = new EntityRegistry(kEntitiesToTest);

            Assert.IsFalse(registry.IsValid(Entity.NullEntity));

            List <Entity> validEntities   = new List <Entity>(kEntitiesToTest * 100);
            List <Entity> invalidEntities = new List <Entity>(kEntitiesToTest * 100);

            for (int i = 0; i < kEntitiesToTest; ++i)
            {
                validEntities.Add(registry.Create());
            }

            Random randomizer = new Random(457);

            while (tests > 0)
            {
                --tests;
                for (int i = validEntities.Count - 1; i >= 0; --i)
                {
                    Entity entity = validEntities[i];
                    if (randomizer.NextDouble() < 0.01)
                    {
                        Assert.IsTrue(registry.IsValid(entity));
                        registry.Destroy(entity);
                        validEntities.RemoveAt(i);
                        invalidEntities.Add(entity);
                    }
                }
                for (int i = validEntities.Count; i < kEntitiesToTest; ++i)
                {
                    if (randomizer.NextDouble() < 0.01)
                    {
                        Entity replacement = registry.Create();
                        validEntities.Add(replacement);
                    }
                }
            }

            foreach (Entity entity in validEntities)
            {
                Assert.IsTrue(registry.IsValid(entity));
            }

            foreach (Entity entity in invalidEntities)
            {
                Assert.IsFalse(registry.IsValid(entity));
            }
        }
Exemplo n.º 24
0
        public void KeyValue(Edict pentKeyvalue, KeyValueData pkvd)
        {
            //Log.Message($"Entity {EntityDictionary.EntityIndex(pentKeyvalue)}/{EntityDictionary.Max} KeyValue ClassName=\"{pkvd.ClassName}\" Key=\"{pkvd.KeyName}\" Value=\"{pkvd.Value}\"");

            if (pkvd.KeyName == "classname")
            {
                if (pentKeyvalue.PrivateData == null)
                {
                    Log.Message($"Creating entity \"{pkvd.Value}\"");

                    //Create the entity instance
                    EntityRegistry.CreateInstance <BaseEntity>(pentKeyvalue);

                    Log.Message("Created entity");
                }
                else
                {
                    var ent = (BaseEntity)pentKeyvalue.PrivateData;

                    //This should never happen
                    if (pkvd.Value != ent.ClassName)
                    {
                        throw new InvalidOperationException($"Second occurence of classname keyvalue has different value (Expected: {ent.ClassName}, actual:{pkvd.Value})");
                    }

                    pkvd.Handled = true;
                    return;
                }
            }

            if (pentKeyvalue.PrivateData == null)
            {
                throw new InvalidOperationException($"Cannot set keyvalue \"{pkvd.KeyName}={pkvd.Value}\" on null entity of class {pkvd.ClassName}");
            }

            pkvd.Handled = false;

            var entity = (BaseEntity)pentKeyvalue.PrivateData;

            //TODO: uniformly handle keyvalue initialization

            switch (pkvd.KeyName)
            {
            case "classname":
            {
                entity.ClassName = pkvd.Value;
                pkvd.Handled     = true;
                break;
            }
            }
        }
Exemplo n.º 25
0
        public void Update(EntityRegistry registry, EventSystem eventSystem)
        {
            int count = mFallingEntities.Entities.Count;

            for (int i = 0; i < count; ++i)
            {
                Vector2 velocityDelta     = Dynamics.NewtonianVelocityDelta(PondSimState.kGravity, mTime); //TODO: Data drive gravity!
                Vector2 newVelocity       = mFallingEntities.Velocities[i].Value + velocityDelta;
                Vector2 frogPositionDelta = Dynamics.NewtonianPositionDelta(mFallingEntities.Velocities[i].Value, PondSimState.kGravity, mTime);
                Vector2 newPosition       = mFallingEntities.Positions[i].Value + frogPositionDelta;
                //TODO: Deferred registry commands
                registry.SetComponent(mFallingEntities.Entities[i], new Velocity(newVelocity));
                registry.SetComponent(mFallingEntities.Entities[i], new Position(newPosition));
            }
        }
Exemplo n.º 26
0
        private void MakeToungue(EntityRegistry registry, Entity parentFrog)
        {
            Entity       toungue = registry.Create();
            ToungueState state   = new ToungueState(ToungueStages.Extending, mData.GetStateTime(ToungueStages.Extending));

            registry.AddComponent(toungue, state);
            registry.AddComponent(toungue, new RectShape());
            registry.AddComponent(toungue, new Position());
            registry.AddComponent(toungue, Color.Red);
            registry.AddComponent(toungue, new ParentEntity(parentFrog, new Vector2()));

            ControlledEntity controlledToungue = new ControlledEntity(toungue);

            registry.AddComponent(parentFrog, controlledToungue);
        }
Exemplo n.º 27
0
        public void Update(EntityRegistry registry, EventSystem eventSystem)
        {
            int count = mMovingFliesSlice.Entity.Count;

            for (int i = 0; i < count; ++i)
            {
                Vector2 newPosition = mMovingFliesSlice.Position[i].Value + mTime.DeltaTime * mMovingFliesSlice.Velocity[i].Value;
                mPositionBuffer[i] = new Position(newPosition);
            }
            //TODO: Is it *really* more efficient to use a buffer?
            for (int i = 0; i < count; ++i)
            {
                registry.SetComponent(mMovingFliesSlice.Entity[i], mPositionBuffer[i]);
            }
        }
Exemplo n.º 28
0
        public Entity MakeFrog(int index, EntityRegistry registry)
        {
            Entity frogEntity = registry.Create();

            //Controller state
            FrogControlState controlState = new FrogControlState();

            registry.AddComponent(frogEntity, controlState);

            //Position Component
            int      spawnIndex    = index % mPondData.FrogSpawns.Length;
            float    spawnX        = mPondData.FrogSpawns[spawnIndex];
            float    spawnY        = mPondData.Height + mFrogData.Height;
            Vector2  positionValue = new Vector2(spawnX, spawnY);
            Position spawnPosition = new Position(positionValue);

            registry.AddComponent(frogEntity, spawnPosition);

            //Facing
            Facing facing = new Facing();

            registry.AddComponent(frogEntity, facing);

            //Velocity
            Velocity velocity = new Velocity();

            registry.AddComponent(frogEntity, velocity);

            //Shape
            RectShape rectShape = new RectShape(mFrogData.Width, mFrogData.Height);

            registry.AddComponent(frogEntity, rectShape);

            //Rect - Added automatically by the RectUpkeepSystem, but I don't want to worry about the first frame this being missing
            Rect rect = new Rect(spawnPosition.Value, rectShape.Width, rectShape.Height);

            //Gravity - Spawned in the air!
            Gravity gravity = new Gravity();

            registry.AddComponent(frogEntity, gravity);

            //Animation
            AnimationState animation = new AnimationState();

            registry.AddComponent(frogEntity, animation);

            return(frogEntity);
        }
Exemplo n.º 29
0
        public Entity MakePlayer(int index, EntityRegistry registry)
        {
            AssertIndexIsNotUsed(index);

            Entity playerEntity = registry.Create();

            registry.AddComponent(playerEntity, new Player(index));

            Entity frogEntity = mFrogFactory.MakeFrog(index, registry);

            ControlledEntity controlledEntity = new ControlledEntity(frogEntity);

            registry.AddComponent(playerEntity, controlledEntity);

            return(playerEntity);
        }
Exemplo n.º 30
0
        /// <summary>
        /// First time database initialization.
        /// </summary>
        /// <param name="entityRegistry">The storage of trade objects.</param>
        /// <param name="databaseRaw">Raw bytes of database file.</param>
        /// <param name="init">Initialization callback.</param>
        /// <returns>Path to the database file.</returns>
        public static string FirstTimeInit(this EntityRegistry entityRegistry, byte[] databaseRaw, Action <Database> init = null)
        {
            if (entityRegistry == null)
            {
                throw new ArgumentNullException(nameof(entityRegistry));
            }

            if (databaseRaw == null)
            {
                throw new ArgumentNullException(nameof(databaseRaw));
            }

            var database = entityRegistry.Storage as Database;

            return(database?.FirstTimeInit(databaseRaw, init));
        }
Exemplo n.º 31
0
    public void Register()
    {
        EntityRegistry = new EntityRegistry();
        LevelRegistry = new LevelRegistry();
        SkillRegistry = new SkillRegistry();
        CategoryRegistry = new CategoryRegistry();
        Anvil = new AnvilRegistry();

        Anvil.GetMods();

        Anvil.ModsPreInit();
        Anvil.ModsLoad();
        Anvil.ModsPostInit();

        RegisterStatsAndCategories();

        Entities.RegisterEntities();
        Skills.RegisterSkills();
        //Levels.RegisterLevels();

        UIMain.GenerateFirstSkills();

        new Character(new Rogue(), new Halfling());
    }