예제 #1
0
        public static World PrepareWorld()
        {
            World world = null;

            WorldUtilities.CreateWorld <TestState>(ref world, 0.033f);
            {
                world.SetState <TestState>(WorldUtilities.CreateState <TestState>());
                world.SetSeed(1u);
                {
                    WorldUtilities.InitComponentTypeId <ME.ECS.Views.ViewComponent>(false);
                    WorldUtilities.InitComponentTypeId <ME.ECS.Name.Name>(false);
                    WorldUtilities.InitComponentTypeId <ME.ECS.Transform.Childs>(false);
                    WorldUtilities.InitComponentTypeId <ME.ECS.Collections.IntrusiveListNode>(false);
                    WorldUtilities.InitComponentTypeId <ME.ECS.Collections.IntrusiveHashSetBucket>(false);
                    world.GetStructComponents().Validate <ME.ECS.Views.ViewComponent>();
                    world.GetStructComponents().Validate <ME.ECS.Name.Name>();
                    world.GetStructComponents().Validate <ME.ECS.Transform.Childs>();
                    world.GetStructComponents().Validate <ME.ECS.Collections.IntrusiveListNode>();
                    world.GetStructComponents().Validate <ME.ECS.Collections.IntrusiveHashSetBucket>();
                    ComponentsInitializerWorld.Setup((e) => {
                        e.ValidateData <ME.ECS.Views.ViewComponent>();
                        e.ValidateData <ME.ECS.Name.Name>();
                        e.ValidateData <ME.ECS.Transform.Childs>();
                        e.ValidateData <ME.ECS.Collections.IntrusiveListNode>();
                        e.ValidateData <ME.ECS.Collections.IntrusiveHashSetBucket>();
                    });
                    //world.SetEntitiesCapacity(1000);
                }
            }

            WorldUtilities.SetWorld(world);

            return(world);
        }
예제 #2
0
        static partial void Init(ref ME.ECS.StructComponentsContainer structComponentsContainer)
        {
            WorldUtilities.ResetTypeIds();

            CoreComponentsInitializer.InitTypeId();


            WorldUtilities.InitComponentTypeId <Example.Features.Logic.DestroyByTime.Components.DestroyByTime>(false, false, false, false, false);
            WorldUtilities.InitComponentTypeId <Example.Features.Logic.ForceAtPoint.Components.AddForce>(false, false, false, false, false);
            WorldUtilities.InitComponentTypeId <Example.Features.Logic.ForceAtPoint.Components.Force>(false, false, false, false, false);
            WorldUtilities.InitComponentTypeId <Example.Features.Map.Components.IsMap>(true, false, false, false, false);
            WorldUtilities.InitComponentTypeId <Example.Features.PlayerFire.Components.BulletFly>(false, false, false, false, false);
            WorldUtilities.InitComponentTypeId <Example.Features.PlayerFire.Components.FireAction>(true, false, false, false, false);
            WorldUtilities.InitComponentTypeId <Example.Features.PlayerFire.Components.IsBullet>(false, false, false, false, false);
            WorldUtilities.InitComponentTypeId <Example.Features.PlayerMovement.Components.LastMovementDirection>(false, false, false, false, false);
            WorldUtilities.InitComponentTypeId <Example.Features.PlayerMovement.Components.MoveAction>(false, false, false, false, false);
            WorldUtilities.InitComponentTypeId <Example.Features.Players.Components.IsPlayer>(true, false, false, false, false);

            ComponentsInitializerWorld.Setup(ComponentsInitializerWorldGen.Init);
            CoreComponentsInitializer.Init(ref structComponentsContainer);


            structComponentsContainer.Validate <Example.Features.Logic.DestroyByTime.Components.DestroyByTime>(false);
            structComponentsContainer.Validate <Example.Features.Logic.ForceAtPoint.Components.AddForce>(false);
            structComponentsContainer.Validate <Example.Features.Logic.ForceAtPoint.Components.Force>(false);
            structComponentsContainer.Validate <Example.Features.Map.Components.IsMap>(true);
            structComponentsContainer.Validate <Example.Features.PlayerFire.Components.BulletFly>(false);
            structComponentsContainer.Validate <Example.Features.PlayerFire.Components.FireAction>(true);
            structComponentsContainer.Validate <Example.Features.PlayerFire.Components.IsBullet>(false);
            structComponentsContainer.Validate <Example.Features.PlayerMovement.Components.LastMovementDirection>(false);
            structComponentsContainer.Validate <Example.Features.PlayerMovement.Components.MoveAction>(false);
            structComponentsContainer.Validate <Example.Features.Players.Components.IsPlayer>(true);
        }
예제 #3
0
 protected override void OnDeconstruct()
 {
     if (this.pathfindingInstance != null)
     {
         this.pathfindingInstance.Recycle();
     }
     this.pathfindingInstance = null;
     ComponentsInitializerWorld.UnRegister(PathfindingComponentsInitializer.InitEntity);
 }
예제 #4
0
        protected override void OnConstruct()
        {
            PathfindingComponentsInitializer.Init(ref this.world.GetStructComponents());
            ComponentsInitializerWorld.Register(PathfindingComponentsInitializer.InitEntity);

            var entity = new Entity("Pathfinding");

            entity.SetData(new IsPathfinding());
            this.pathfindingEntity = entity;

            this.AddSystem <SetPathfindingInstanceSystem>();
            this.AddSystem <BuildGraphsSystem>();
            this.AddSystem <BuildPathSystem>();
            this.AddSystem <PathfindingUpdateSystem>();
        }
예제 #5
0
        public void WorldSerialization()
        {
            World CreateWorld()
            {
                World world = null;

                WorldUtilities.CreateWorld <TestState>(ref world, 0.033f);
                {
                    world.AddModule <TestStatesHistoryModule>();
                    world.AddModule <FakeNetworkModule>();

                    world.SetState <TestState>(WorldUtilities.CreateState <TestState>());

                    //components
                    {
                        ref var sc = ref world.GetStructComponents();
                        ComponentsInitializerWorld.Setup(e => e.ValidateData <TestStructComponent>());
                        CoreComponentsInitializer.Init(ref sc);
                        sc.Validate <TestStructComponent>();
                    }
                    //settings
                    {
                        world.SetSettings(new WorldSettings {
                            useJobsForSystems = false,
                            useJobsForViews   = false,
                            turnOffViews      = false,
                            viewsSettings     = new WorldViewsSettings()
                        });
                        world.SetDebugSettings(WorldDebugSettings.Default);
                    }

                    var group = new SystemGroup(world, "GroupName");
                    group.AddSystem <TestSystem>();
                }

                var ent = new Entity("Test Entity");

                ent.SetPosition(UnityEngine.Vector3.zero);
                ent.SetData(new TestStructComponent());

                world.SaveResetState <TestState>();

                return(world);
            }
예제 #6
0
 protected override void OnDeconstruct()
 {
     ComponentsInitializerWorld.UnRegister(PathfindingComponentsInitializer.InitEntity);
 }