Ejemplo n.º 1
0
 public void Clear()
 {
     foreach (Entity e in characters.Values)
     {
         if (World.EntityManager.Exists(e))
         {
             if (World.EntityManager.HasComponent <Controller>(e))
             {
                 playerSpawnSystem.RemoveControllerCharacter(e);
             }
             World.EntityManager.DestroyEntity(e);
         }
     }
     characters.Clear();
 }
Ejemplo n.º 2
0
        private void StartDying(Entity statsEntity, int zoxID)
        {
            float3 position = World.EntityManager.GetComponentData <Translation>(statsEntity).Value;

            if (World.EntityManager.HasComponent <Character>(statsEntity))
            {
                CharacterDatam characterDatam = characterSpawnSystem.meta[World.EntityManager.GetComponentData <Character>(statsEntity).metaID];
                for (int i = 0; i < characterDatam.dropItems.Count; i++)
                {
                    ItemDatam itemToDrop = characterDatam.dropItems[i].GetItem();
                    itemSpawnSystem.QueueItem(position,// + new float3(UnityEngine.Random.Range(-1f, 1f), 0, UnityEngine.Random.Range(-1f, 1f)),
                                              itemToDrop, characterDatam.dropItems[i].GetQuantity());
                }
            }

            playerSpawnSystem.RemoveControllerCharacter(statsEntity);

            // game stuff
            if (World.EntityManager.HasComponent <Skills>(statsEntity))
            {
                World.EntityManager.RemoveComponent <Skills>(statsEntity);
            }
            skillsSystem.RemoveSkills(statsEntity);
            if (World.EntityManager.HasComponent <Stats>(statsEntity))
            {
                World.EntityManager.RemoveComponent <Stats>(statsEntity);
            }
            if (World.EntityManager.HasComponent <BulletHitTaker>(statsEntity))
            {
                World.EntityManager.RemoveComponent <BulletHitTaker>(statsEntity);
            }
            // movement
            if (World.EntityManager.HasComponent <Body>(statsEntity))
            {
                World.EntityManager.RemoveComponent <Body>(statsEntity);
            }
            if (World.EntityManager.HasComponent <WorldBound>(statsEntity))
            {
                World.EntityManager.RemoveComponent <WorldBound>(statsEntity);
            }
            if (World.EntityManager.HasComponent <BodyForce>(statsEntity))
            {
                World.EntityManager.RemoveComponent <BodyForce>(statsEntity);
            }
            if (World.EntityManager.HasComponent <BodyTorque>(statsEntity))
            {
                World.EntityManager.RemoveComponent <BodyTorque>(statsEntity);
            }
            if (World.EntityManager.HasComponent <BodyInnerForce>(statsEntity))
            {
                World.EntityManager.RemoveComponent <BodyInnerForce>(statsEntity);
            }
            // ai
            if (World.EntityManager.HasComponent <Targeter>(statsEntity))
            {
                World.EntityManager.RemoveComponent <Targeter>(statsEntity);
            }
            if (World.EntityManager.HasComponent <Wander>(statsEntity))
            {
                World.EntityManager.RemoveComponent <Wander>(statsEntity);
            }
            if (World.EntityManager.HasComponent <Mover>(statsEntity))
            {
                World.EntityManager.RemoveComponent <Mover>(statsEntity);
            }
            if (World.EntityManager.HasComponent <AIState>(statsEntity))
            {
                World.EntityManager.RemoveComponent <AIState>(statsEntity);
            }
            else
            {
                CrosshairSpawnSystem.RemoveUI(World.EntityManager, statsEntity);
            }

            // int uiIndex = StatbarSystem.GetListIndex(statsComponent.id);
            if (StatbarSystem.frontBars.ContainsKey(zoxID))
            //   if (uiIndex != -1)
            {
                Entity    characterHealthBar = StatbarSystem.frontBars[zoxID];
                StatBarUI statBar1           = World.EntityManager.GetComponentData <StatBarUI>(characterHealthBar);
                statBar1.isDead           = 1;
                statBar1.targetPercentage = 0;
                //statBar1.timeStateChanged = UnityEngine.Time.time;
                World.EntityManager.SetComponentData(characterHealthBar, statBar1);
            }
            if (characterSpawnSystem.characters.ContainsKey(zoxID))
            {
                characterSpawnSystem.characters.Remove(zoxID);
            }
            World.EntityManager.AddComponentData(statsEntity, new DyingOne
            {
                timeOfDeath = UnityEngine.Time.time
            });
            if (TurretSpawnerSystem.bases.ContainsKey(zoxID))
            {
                World.EntityManager.AddComponentData(TurretSpawnerSystem.bases[zoxID], new ScaleLerper
                {
                    createdTime = UnityEngine.Time.time,
                    lifeTime    = deadbodyRemovalTime,
                    scaleBegin  = World.EntityManager.GetComponentData <NonUniformScale>(TurretSpawnerSystem.bases[zoxID]).Value,
                    scaleEnd    = float3.zero
                });
            }
            World.EntityManager.AddComponentData(statsEntity, new ScaleLerper
            {
                createdTime = UnityEngine.Time.time,
                lifeTime    = deadbodyRemovalTime,
                scaleBegin  = World.EntityManager.GetComponentData <NonUniformScale>(statsEntity).Value,
                scaleEnd    = float3.zero
            });
        }