Example #1
0
        public override void Generate(CityConfig config)
        {
            base.Generate(config);
            gameObject.AddComponent <GameObjectEntity>();
            LinkedStartNode = StartNode.GenTimePointer.GetComponent <GameObjectEntity>();
#if CITY_DEBUG
            if (EndNode == null || EndNode.GenTimePointer == null)
            {
                Debug.Log(GetGameObjectPath(this.transform));
                int abc = 123;
            }
#endif
            LinkedEndNode = EndNode.GenTimePointer.GetComponent <GameObjectEntity>();
            gameObject.AddComponent <SplineProxy>().Value = ComputeBezierPoints();
            var trafficType = GetComponentInParent <RoadSegment>().GetConnectionTrafficType(this);
            gameObject.AddComponent <ConnectionTrafficProxy>().Value = new ConnectionTraffic
            {
                TrafficType = trafficType,
            };
            int conLen = ComputeLength().ToCityInt();
            gameObject.AddComponent <ConnectionLengthIntProxy>().Value = new ConnectionLengthInt
            {
                Length = conLen,
            };
            gameObject.AddComponent <ConnectionStateIntProxy>().Value = new ConnectionStateInt
            {
                EnterLen = conLen,
            };
            gameObject.AddComponent <ConnectionPullIntProxy>().Value = new ConnectionPullInt
            {
                Pull = 0,
            };
            gameObject.AddComponent <ConnectionPullQIntProxy>().Value = new ConnectionPullQInt
            {
                PullQ = 0,
            };
            gameObject.AddComponent <NetworkGroupStateProxy>().Value = new NetworkGroupState
            {
                NetworkId = -1,
            };
//			gameObject.AddComponent<NetworkGroupProxy>().Value = new NetworkGroup
//			{
//				NetworkId = -1,
//			};
            CachedSpeed = config.ConnectionBaseSpeed / config.TargetFramerate *
                          GetComponentInParent <RoadSegment>().SpeedMultiplier;
            gameObject.AddComponent <ConnectionSpeedIntProxy>().Value = new ConnectionSpeedInt
            {
                Speed = CachedSpeed.ToCityInt(),
            };

            var marker = gameObject.GetComponent <TargetMarker>();
            if (marker != null)
            {
                gameObject.AddComponent <TargetProxy>().Value = new Target
                {
                    TargetMask = (int)marker.TargetMask,
                };
            }
        }
Example #2
0
    public void Speed1_Move()
    {
        var entity = new GameObject();

        entity.AddComponent <GameObjectEntity>();
        entity.AddComponent <CharWrapper>();
        entity.AddComponent <PositionHybrid>();
        GameObjectEntity.AddToEntityManager(_entityManager, entity);

        // act
        var system = _world.GetOrCreateManager <CharMoveSystem>();

        system.Update();
        _entityManager.CompleteAllJobs();

        // assert
        //确实进入到system的监视列表中
        Assert.AreEqual(1, system.CharGroup.CalculateLength());

        //手动创建的gameobject与由他产生的entity确实是关联的,
        Assert.AreSame(entity.GetComponent <PositionHybrid>(),
                       system.CharGroup.GetComponentArray <PositionHybrid>()[0]);
        Assert.AreEqual(new float3(1, 1, 1), entity.GetComponent <PositionHybrid>().Value);
        Assert.AreEqual(new float3(1, 1, 1),
                        system.CharGroup.GetComponentArray <PositionHybrid>()[0].Value);
    }
Example #3
0
        /// <summary>
        /// Setup paths:
        /// Creating Pure Entity
        /// Adding Buffer of Curve Entities
        /// Maping PathEntity with PathGO ir Database
        /// </summary>
        private static void SetupPaths()
        {
            GameObject[] pathsGO = GetGameObjectsByTag("Path");
            foreach (var path in pathsGO)
            {
                // Setup Traveler object-entity
                GameObject travelerGO  = path.GetComponent <TravelerSetter>().traveler;
                Entity     travelerEnt = GameObjectEntity.AddToEntityManager(em, travelerGO);
                em.AddComponentData(travelerEnt, new PathID(path.GetInstanceID()));
                em.AddSharedComponentData(travelerEnt, new TravelerMarker {
                });
                Database.Travelers.Add(path.GetInstanceID(), travelerEnt);

                // Setup Path Entity
                Entity pathEntity = em.CreateEntity(Archetypes.PathSplineArchetype);
                em.SetComponentData(pathEntity, new Traveler(travelerEnt));
                em.SetComponentData(pathEntity, new PathID(path.GetInstanceID()));
                em.SetComponentData(pathEntity, new UpdateIndicator(1));

                List <Entity> tempCurvesEntities = SetupCurves(path);
                em.SetComponentData(pathEntity, new Traveler());



                // Saving curves into path
                DynamicBuffer <CurveElement> pathCurvesBuffer = em.GetBufferFromEntity <CurveElement>()[pathEntity];
                foreach (var ce in tempCurvesEntities)
                {
                    pathCurvesBuffer.Add(new CurveElement(ce));
                }

                Database.worldPaths.Add(path.GetInstanceID(), pathEntity);
                Database.ID_GOmap.Add(path.GetInstanceID(), path);
            }
        }
Example #4
0
 protected override void OnUpdate()
 {
     ForEach((Transform transform) =>
     {
         GameObjectEntity.CopyAllComponentsToEntity(transform.gameObject, DstEntityManager, GetPrimaryEntity(transform));
     });
 }
        public void GameObjectEntityNotAdded()
        {
            var go     = new GameObject("test", typeof(GameObjectEntity));
            var entity = GameObjectEntity.AddToEntityManager(m_Manager, go);

            Assert.Throws <ArgumentException>(() => { m_Manager.HasComponent <GameObjectEntity>(entity); });
        }
Example #6
0
        private void OnValidate()
        {
            m_Camera           = GetComponent <UnityEngine.Camera>();
            m_GameObjectEntity = GetComponent <GameObjectEntity>();

            RefreshData(true);
        }
Example #7
0
    protected override void OnUpdate()
    {
        //HACK + TODO -> just adding this here to force the system to update
        Entities.ForEach((Entity entity) => { });

        Entities.ForEach((Entity entity, ref EventComponentData eventData, Transform transform) =>
        {
            if (Application.isPlaying)
            {
                GameObjectEntity.Destroy(transform.gameObject);
            }
            else
            {
                GameObjectEntity.DestroyImmediate(transform.gameObject);
            }
        });

        Entities.ForEach((Entity entity, ref EventComponentData eventData) =>
        {
            PostUpdateCommands.DestroyEntity(entity);
        });

        foreach (var kvp in dataEvents)
        {
            kvp.Value.Update(EntityManager);
        }
        dataEvents?.Clear();

        foreach (var kvp in objectEvents)
        {
            kvp.Value.Update(EntityManager);
        }
        objectEvents?.Clear();
    }
Example #8
0
        // Create Game Object on World
        internal static UpdateObject CreateGameObject(zoneObjeto gameObject)
        {
            BinaryWriter writer = new BinaryWriter(new MemoryStream());

            writer.Write((byte)ObjectUpdateType.UPDATETYPE_CREATE_OBJECT);

            GameObjectEntity entity = new GameObjectEntity(gameObject);

            writer.WritePackedUInt64(entity.ObjectGuid.RawGuid);

            writer.Write((byte)TypeId.TypeidGameobject);

            ObjectUpdateFlag updateFlags = ObjectUpdateFlag.UpdateflagTransport |
                                           ObjectUpdateFlag.UpdateflagAll |
                                           ObjectUpdateFlag.UpdateflagHasPosition;

            writer.Write((byte)updateFlags);

            writer.Write(gameObject.map.mapX);
            writer.Write(gameObject.map.mapY);
            writer.Write(gameObject.map.mapZ);

            writer.Write((float)0);

            writer.Write((uint)0x1);
            writer.Write((uint)0);

            entity.WriteUpdateFields(writer);

            return(new UpdateObject(new List <byte[]> {
                (writer.BaseStream as MemoryStream)?.ToArray()
            }, 1));
        }
Example #9
0
        unsafe public void ComponentEnumerator()
        {
            var go     = new GameObject("test", typeof(Rigidbody), typeof(Light));
            var entity = GameObjectEntity.AddToEntityManager(m_Manager, go);

            m_Manager.AddComponentData(entity, new EcsTestData(5));
            m_Manager.AddComponentData(entity, new EcsTestData2(6));

            var cache = new ComponentGroupArrayStaticCache(typeof(MyEntity), m_Manager);

            var array      = new ComponentGroupArray <MyEntity>(cache);
            int iterations = 0;

            foreach (var e in array)
            {
                Assert.AreEqual(5, e.testData->value);
                Assert.AreEqual(6, e.testData2->value0);
                Assert.AreEqual(go.GetComponent <Light>(), e.light);
                Assert.AreEqual(go.GetComponent <Rigidbody>(), e.rigidbody);
                iterations++;
            }
            Assert.AreEqual(1, iterations);

            cache.Dispose();
            Object.DestroyImmediate(go);
        }
Example #10
0
    public static void Start()
    {
        //获取Cube
        GameObjectEntity cubeEntity = GameObject.Find("Cube").AddComponent <GameObjectEntity>();

        //添加Velocity组件
        entityManager.AddComponentData(cubeEntity.Entity, new VelocityComponent
        {
            moveDir = new Unity.Mathematics.float3(0, 1, 0)
        });


        //把GameObect.Find放在这里因为场景加载完成前无法获取游戏物体。
        GameObject playerGo = GameObject.Find("Player");

        //下面的类型是一个Struct, 需要引入Unity.Rendering命名空间
        MeshInstanceRenderer playerRenderer =
            playerGo.GetComponent <MeshInstanceRendererComponent>().Value;

        Object.Destroy(playerGo);                                    //获取到渲染数据后可以销毁空物体

        Entity player = entityManager.CreateEntity(playerArchetype); // Position

        //添加PlayerComponent组件
        entityManager.AddComponentData(player, new PlayerComponent());   // PlayerComponent
        entityManager.AddComponentData(player, new VelocityComponent()); // VelocityComponent
        entityManager.AddComponentData(player, new InputComponent());    // InputComponent
        // 向实体添加共享的数据
        entityManager.AddSharedComponentData(player, playerRenderer);    // MeshInstanceRenderer

        //修改实体的Position组件
        entityManager.SetComponentData(player, new Position {
            Value = new Unity.Mathematics.float3(0, 0.5f, 0)
        });
    }
Example #11
0
    protected override void OnUpdate()
    {
        var requestArray = Group.GetComponentDataArray <NameboardSpawnRequest>();
        var entityArray  = Group.GetEntityArray();

        var spawnRequests = new NameboardSpawnRequest[requestArray.Length];

        for (var i = 0; i < requestArray.Length; i++)
        {
            spawnRequests[i] = requestArray[i];
            PostUpdateCommands.DestroyEntity(entityArray[i]);
        }

        for (var i = 0; i < spawnRequests.Length; i++)
        {
            var request = spawnRequests[i];
            GameObjectEntity nameboardGOE = m_world.Spawn <GameObjectEntity>(ResMgr.GetInstance().GetPrefab("Nameboard"));
            nameboardGOE.transform.SetParent(nameboardCanvas);
            var    nameboardBehav = nameboardGOE.GetComponent <Nameboard>();
            var    uid            = EntityManager.GetComponentData <UID>(request.Owner);
            string name           = SceneMgr.Instance.GetNameByUID(uid.Value);
            nameboardBehav.Name = name;
            var isMainRole = RoleMgr.GetInstance().IsMainRoleEntity(request.Owner);
            nameboardBehav.CurColorStyle = isMainRole ? Nameboard.ColorStyle.Green : Nameboard.ColorStyle.Red;
            if (EntityManager.HasComponent <NameboardData>(request.Owner))
            {
                var nameboardData = EntityManager.GetComponentData <NameboardData>(request.Owner);
                nameboardData.UIEntity   = nameboardGOE.Entity;
                nameboardData.UIResState = NameboardData.ResState.Loaded;
                EntityManager.SetComponentData(request.Owner, nameboardData);
            }
        }
    }
Example #12
0
    protected override void OnUpdate()
    {
        // Debug.Log("on OnUpdate role looks system");
        var requestArray = SpawnGroup.ToComponentDataArray <RoleLooksSpawnRequest>(Allocator.TempJob);

        if (requestArray.Length == 0)
        {
            requestArray.Dispose();
            return;
        }

        var requestEntityArray = SpawnGroup.ToEntityArray(Allocator.TempJob);

        // Copy requests as spawning will invalidate Group
        var spawnRequests = new RoleLooksSpawnRequest[requestArray.Length];

        for (var i = 0; i < requestArray.Length; i++)
        {
            spawnRequests[i] = requestArray[i];
            PostUpdateCommands.DestroyEntity(requestEntityArray[i]);
        }

        for (var i = 0; i < spawnRequests.Length; i++)
        {
            var request = spawnRequests[i];
            // var playerState = EntityManager.GetComponentObject<RoleState>(request.ownerEntity);
            var looksInfo = EntityManager.GetComponentData <LooksInfo>(request.ownerEntity);
            int career    = request.career;
            int body      = request.body;
            int hair      = request.hair;
            // Debug.Log("body : "+body+" hair:"+hair);
            string bodyPath = ResPath.GetRoleBodyResPath(career, body);
            string hairPath = ResPath.GetRoleHairResPath(career, hair);
            // Debug.Log("SpawnRoleLooks bodyPath : "+bodyPath);
            XLuaFramework.ResourceManager.GetInstance().LoadAsset <GameObject>(bodyPath, delegate(UnityEngine.Object[] objs) {
                if (objs != null && objs.Length > 0)
                {
                    GameObject bodyObj        = objs[0] as GameObject;
                    GameObjectEntity bodyOE   = m_world.Spawn <GameObjectEntity>(bodyObj);
                    var parentTrans           = EntityManager.GetComponentObject <Transform>(request.ownerEntity);
                    parentTrans.localPosition = request.position;
                    bodyOE.transform.SetParent(parentTrans);
                    bodyOE.transform.localPosition = Vector3.zero;
                    bodyOE.transform.localRotation = Quaternion.identity;
                    ECSHelper.UpdateNameboardHeight(request.ownerEntity, bodyOE.transform);
                    LoadHair(hairPath, bodyOE.transform.Find("head"));
                    // Debug.Log("load ok role model");
                    looksInfo.CurState    = LooksInfo.State.Loaded;
                    looksInfo.LooksEntity = bodyOE.Entity;
                    EntityManager.SetComponentData <LooksInfo>(request.ownerEntity, looksInfo);
                }
                else
                {
                    Debug.LogError("cannot fine file " + bodyPath);
                }
            });
        }
        requestEntityArray.Dispose();
        requestArray.Dispose();
    }
    protected override void OnUpdate()
    {
        //HACK + TODO -> force the system to update
        Entities.ForEach((Entity entity) => { });

        Entities.ForEach((Entity entity, ref EventComponentData eventData, Transform transform) =>
        {
            GameObjectEntity.Destroy(transform.gameObject);
        });

        Entities.ForEach((Entity entity, ref EventComponentData eventData) =>
        {
            PostUpdateCommands.DestroyEntity(entity);
        });

        foreach (var kvp in dataEvents)
        {
            kvp.Value.Update(EntityManager);
        }
        dataEvents?.Clear();

        foreach (var kvp in objectEvents)
        {
            kvp.Value.Update(EntityManager);
        }
        objectEvents?.Clear();
    }
Example #14
0
    protected override void OnUpdate()
    {
        // Debug.Log("on OnUpdate role looks system");
        var requestArray = SpawnGroup.GetComponentDataArray <RoleLooksSpawnRequest>();

        if (requestArray.Length == 0)
        {
            return;
        }

        var requestEntityArray = SpawnGroup.GetEntityArray();

        // Copy requests as spawning will invalidate Group
        var spawnRequests = new RoleLooksSpawnRequest[requestArray.Length];

        for (var i = 0; i < requestArray.Length; i++)
        {
            spawnRequests[i] = requestArray[i];
            PostUpdateCommands.DestroyEntity(requestEntityArray[i]);
        }

        for (var i = 0; i < spawnRequests.Length; i++)
        {
            var request = spawnRequests[i];
            // var playerState = EntityManager.GetComponentObject<RoleState>(request.ownerEntity);
            var looksInfo = EntityManager.GetComponentData <LooksInfo>(request.ownerEntity);
            int career    = request.career;
            int body      = request.body;
            int hair      = request.hair;
            Debug.Log("body : " + body + " hair:" + hair);
            int bodyID = 1000 + career * 100 + body;
            int hairID = 1000 + career * 100 + hair;
            // string careerPath = UnityMMO.GameConst.GetRoleCareerResPath(career);
            string roleResPath = "Assets/AssetBundleRes/role";
            string bodyPath    = roleResPath + "/body/body_" + bodyID + "/model_body_" + bodyID + ".prefab";
            string hairPath    = roleResPath + "/hair/hair_" + hairID + "/model_hair_" + hairID + ".prefab";
            Debug.Log("SpawnRoleLooks bodyPath : " + bodyPath);
            XLuaFramework.ResourceManager.GetInstance().LoadAsset <GameObject>(bodyPath, delegate(UnityEngine.Object[] objs) {
                if (objs != null && objs.Length > 0)
                {
                    GameObject bodyObj        = objs[0] as GameObject;
                    GameObjectEntity bodyOE   = m_world.Spawn <GameObjectEntity>(bodyObj);
                    var parentTrans           = EntityManager.GetComponentObject <Transform>(request.ownerEntity);
                    parentTrans.localPosition = request.position;
                    bodyOE.transform.SetParent(parentTrans);
                    bodyOE.transform.localPosition = Vector3.zero;
                    bodyOE.transform.localRotation = Quaternion.identity;
                    LoadHair(hairPath, bodyOE.transform.Find("head"));
                    Debug.Log("load ok role model");
                    looksInfo.CurState    = LooksInfo.State.Loaded;
                    looksInfo.LooksEntity = bodyOE.Entity;
                    EntityManager.SetComponentData <LooksInfo>(request.ownerEntity, looksInfo);
                }
                else
                {
                    Debug.LogError("cannot fine file " + bodyPath);
                }
            });
        }
    }
Example #15
0
        public Entity CreateEntity()
        {
            if (this._gameObjectEntity != null)
            {
                return(this.Entity);
            }

            this._gameObjectEntity = this.gameObject.GetComponent <GameObjectEntity>();
            if (this._gameObjectEntity == null)
            {
                this._gameObjectEntity = this.gameObject.AddComponent <GameObjectEntity>();
            }
            this.Entity = this._gameObjectEntity.Entity;

            var entity = this.Entity;

            this._entityManager.AddComponentData(
                entity, new ColliderGroupInstanceID {
                Value = this.GetInstanceID()
            });
            this._entityManager.AddComponentData(
                entity, new ColliderGroupBlittableFieldsPtr()
            {
                Value  = (BlittableFields *)this._blittableFieldsArray.GetUnsafeReadOnlyPtr(),
                Length = this._blittableFieldsArray.Length,
            });
            return(entity);
        }
Example #16
0
    public void InintCharacter(uint uid, bool isSelf = true, bool isNet = false)
    {
        GameObjectEntity gameObjectEntity = GetComponent <GameObjectEntity>();

        thisEntity    = gameObjectEntity.Entity;
        entityManager = gameObjectEntity.EntityManager;

        userID  = uid;
        _isSelf = isSelf;
        _isNet  = isNet;

        SetUpMoveComponent();
        SetupAnimationComponent();
        SetupJumpComponent();
        SetupSimpleAttackComponent();
        SetUpEffectComponent();
        SetUpUserDataComponent(uid, isSelf);
        SetUpInjuryComponent();
        SetUpShotDownComponent();
        if (isNet)
        {
            SetUpNetInputComponent();
            SetUpNetSyncComponent();
        }
        else if (isSelf)
        {
            SetupCustomInputComponent();
        }
    }
Example #17
0
        /// <summary>
        /// Initiates base entity to work with tweens ( internal function )
        /// </summary>
        /// <param name="go">GameObject</param>
        /// <param name="time">Interpolation time</param>
        /// <param name="easing">Easing type</param>
        private static Entity BaseTween(GameObject go, float time, EasingType easing = EasingType.Linear)
        {
            var entityManager = World.Active.GetExistingManager <EntityManager>();

            // Link a (new) entity with an existing GameObject
            var entity = GameObjectEntity.AddToEntityManager(entityManager, go);

            // Add our componentDatas
            entityManager.AddComponentData(entity, new TweenTime());
            entityManager.AddComponentData(entity, new TweenLifetime()
            {
                StartTime = Time.time, Lifetime = time
            });

            // Setup easing componentdata depending on easing type
            switch (easing)
            {
            case EasingType.ExpIn:
                entityManager.AddComponentData(entity, new TweenEasingExpIn());
                break;

            case EasingType.ExpOut:
                entityManager.AddComponentData(entity, new TweenEasingExpOut());
                break;

            case EasingType.Linear:
            // Nothing happens here since we don't need to modify the normalized time value
            default:
                break;
            }

            return(entity);
        }
Example #18
0
 public void Update(EntityManager entityManager)
 {
     foreach (var evt in Queue)
     {
         var entity = GameObjectEntity.AddToEntityManager(entityManager, evt.gameObject);
         entityManager.AddComponentData(entity, new EventComponentData());
     }
 }
Example #19
0
 public void AddGameObjectEntity(gameobject gameObject)
 {
     var guid = new ObjectGUID((ulong)gameObject.guid, TypeID.TYPEID_GAMEOBJECT);
     var template = vanillaWorld.WorldDatabase.GetRepository<gameobject_template>().SingleOrDefault(t => t.entry == gameObject.id);
     var gameObjectEntity = new GameObjectEntity(guid, gameObject, template);
     GameObjectEntities.Add(gameObjectEntity);
     gameObjectEntity.Setup();
 }
Example #20
0
    public static Entity RegisterAudioUser(AudioUser audioUser)
    {
        Entity audioUserEntity = GameObjectEntity.AddToEntityManager(s_entityManager, audioUser.gameObject);

        s_entityManager.AddComponentData(audioUserEntity, new Position(audioUser.transform.position));
        s_entityManager.AddComponentData(audioUserEntity, new CopyTransformFromGameObject());
        return(audioUserEntity);
    }
Example #21
0
 private void Awake()
 {
     EntityObject = GetComponent <GameObjectEntity>();
     if (EntityObject != null)
     {
         _entity = EntityObject.Entity;
     }
 }
        public void SetUp()
        {
            var parent = new GameObject($"{TestContext.CurrentContext.Test.Name}-PARENT");

            m_TestObjects[ActivateTestObject.Parent] = parent;
            m_GameObjectEntity = new GameObject(TestContext.CurrentContext.Test.Name, typeof(GameObjectEntity)).GetComponent <GameObjectEntity>();
            m_GameObjectEntity.gameObject.transform.SetParent(parent.transform);
            m_TestObjects[ActivateTestObject.Child] = m_GameObjectEntity.gameObject;
        }
        // -------- -------- -------- -------- -------- -------- -------- -------- -------- /.
        // Unity Methods
        // -------- -------- -------- -------- -------- -------- -------- -------- -------- /.
        private void Awake()
        {
            m_GameObjectEntity = GetComponent <GameObjectEntity>();

            var manager = World.Active.GetOrCreateManager <CGameEntityGroupManager>();
            var group   = manager.AttachBehaviour(this);

            manager.AttachTo(m_GameObjectEntity.Entity, group);
        }
Example #24
0
    public void RegisterPrefabToDefaultWorld(GameObject obj)
    {
        if (DefManager == null || DefWorld == null)
        {
            return;
        }

        GameObjectEntity.AddToEntityManager(DefManager, obj);
    }
Example #25
0
        // -------- -------- -------- -------- -------- -------- -------- -------- -------- /.
        // Unity Methods
        // -------- -------- -------- -------- -------- -------- -------- -------- -------- /.
        private void Awake()
        {
            m_GameObjectEntity = GetComponent <GameObjectEntity>()
                                 ?? gameObject.AddComponent <GameObjectEntity>();

            AwakeBeforeFilling();
            FillEntityData();
            AwakeAfterFilling();
        }
Example #26
0
        public void AddGameObjectEntity(gameobject gameObject)
        {
            var guid             = new ObjectGUID((ulong)gameObject.guid, TypeID.TYPEID_GAMEOBJECT);
            var template         = vanillaWorld.WorldDatabase.GetRepository <gameobject_template>().SingleOrDefault(t => t.entry == gameObject.id);
            var gameObjectEntity = new GameObjectEntity(guid, gameObject, template);

            GameObjectEntities.Add(gameObjectEntity);
            gameObjectEntity.Setup();
        }
        public void GameObjectEntityNotAdded()
        {
            var go     = new GameObject("test", typeof(GameObjectEntity));
            var entity = GameObjectEntity.AddToEntityManager(m_Manager, go);

            var x = Assert.Throws <ArgumentException>(() => { m_Manager.HasComponent <GameObjectEntity>(entity); });

            Assert.That(x.Message, Contains.Substring("All ComponentType must be known at compile time"));
        }
        public void UpdateInjectedComponentGroups_WhenObjectWithMatchingComponentExists_GameObjectArrayIsPopulated()
        {
            m_GameObject.AddComponent <BoxCollider>();
            GameObjectEntity.AddToEntityManager(m_Manager, m_GameObject);
            var manager = World.GetOrCreateManager <GameObjectArraySystem>();

            manager.UpdateInjectedComponentGroups();

            Assert.That(manager.group.gameObjects.ToArray(), Is.EqualTo(new[] { m_GameObject }));
        }
Example #29
0
    public void SetupDefender()
    {
        GameObjectEntity Ent = GetComponent <GameObjectEntity>();

        if (Ent != null && Ent.EntityManager != null)
        {
            Ent.EntityManager.AddComponentData(Ent.Entity, new Defender());
        }
        _isDefender = true;
    }
Example #30
0
        private static void OnGameObjectUsePacket(WorldSession session, PCGameObjectUse packet)
        {
            GameObjectEntity gameObject = session.Core.GetComponent <EntityComponent>().GameObjectEntities.SingleOrDefault(g => g.ObjectGUID.RawGUID == packet.GUID);

            gameobject_template template = gameObject.Template;

            if (gameObject != null && GameObjectUseHandlers.ContainsKey((GameObjectType)template.type))
            {
                GameObjectUseHandlers[(GameObjectType)template.type](session, gameObject);
            }
        }
Example #31
0
 void CreateGameObject(GameObjectEntity entity)
 {
     if (entity.isClient)
     {
         GameObject prefab = (GameObject)Resources.Load(entity.path);
         var        go     = Instantiate(prefab, new Vector3(0, 0, 0), Quaternion.identity);
         var        view   = go.GetComponent <URSView>();
         view.viewID = entity.viewID;
         views.Add(view);
     }
 }
Example #32
0
 void CreateNewGameObjectEntity()
 {
     GameObjectEntity entity = new GameObjectEntity(name, GameObjectEntityList.Count);
     activeGameObjectIndex = GameObjectEntityList.Count;
     GameObjectEntityList.Add(entity);
 }
 public GameObjectPacketBuilder(GameObjectEntity entity)
 {
     this.entity = entity;
 }
Example #34
0
 private static void OnUseChair(WorldSession session, GameObjectEntity gameObjectEntity)
 {
     session.Player.TeleportTo(session.Player.Character.map, gameObjectEntity.Location.X, gameObjectEntity.Location.Y, gameObjectEntity.Location.Z, gameObjectEntity.Location.Orientation);
     session.Player.Info.StandState = (byte)UnitStandStateType.UNIT_STAND_STATE_SIT_CHAIR;
 }