public void OnActionSpawn(ActionStateEvent state)
        {
            var focus = state.Focus;

            if (focus == null)
            {
                return;
            }
            var rect = World.Get <CharacterRectSystem>().GetEntityRect(focus);

            //if (focus == null || !focus.HasComponent<PlayerComponent>()) {
            //    return;
            //}
            if (rect == null)
            {
                return;
            }
            if (_matSource == null)
            {
                _matSource = GetComponent <Renderer>();
            }
            var spawn       = ItemPool.Spawn(StringConst.ParticleUI, false, false);
            var altParticle = spawn.GetComponent <UIAnimation>();

            if (altParticle == null)
            {
                Debug.LogErrorFormat("{0} tried to convert to UI animation for {1} targeting {2} at state {3} spawn {4}", name, state.State, focus.Get <LabelComponent>(), state, spawn.name);
                ItemPool.Despawn(spawn);
                return;
            }
            altParticle.transform.SetParent(rect.RectTr);
            altParticle.Play(_animationUi, _matSource != null ? _matSource.sharedMaterial : null);
            ItemPool.Despawn(gameObject);
        }
        private void SpawnModel(Transform parent)
        {
            var model = ItemPool.Spawn(_modelName);

            if (parent != null)
            {
                model.transform.SetParentResetPos(parent);
            }
            _loadedModel = model.GetComponent <IModelComponent>();
            if (_loadedModel == null)
            {
                ItemPool.Despawn(model.gameObject);
                return;
            }
            var entity = this.GetEntity();

            MonoBehaviourToEntity.RegisterToEntity(model.gameObject, entity);
            _loadedComponents.Add(entity.Add(new ModelComponent(_loadedModel)));
            entity.Tr = model.Transform;
            _loadedComponents.Add(entity.Add(new FloatingTextStatusComponent(model.Transform, new Vector3(0, 1.5f, 0))));
            var animTr = model.GetComponent <IAnimTr>();

            if (animTr != null)
            {
                _loadedComponents.Add(entity.Add(new AnimTr(animTr.AnimTr)));
            }
            var rb = model.GetComponent <Rigidbody>();

            if (rb != null)
            {
                _loadedComponents.Add(entity.Add(new RigidbodyComponent(rb)));
            }
        }
Example #3
0
 void Update()
 {
     if (Application.isPlaying && Canvas.alpha > 0.5f)
     {
         UpdatePermText("Global", string.Format("Active {0} Paused {1} PausedMod {2}", Game.GameActive, Game.Paused, Game.PauseHolder.LastId()));
     }
     for (int i = _tempText.Count - 1; i >= 0; i--)
     {
         if (!_tempText[i].Time.IsActive)
         {
             ItemPool.Despawn(_tempText[i].TextObject);
             _tempText[i].TextObject = null;
             _textTimers.Store(_tempText[i]);
             _tempText.RemoveAt(i);
         }
     }
     if (_threadedText.Count > 0)
     {
         var    count = _threadedText.Count;
         string text;
         for (int i = 0; i < count; i++)
         {
             if (_threadedText.TryDequeue(out text))
             {
                 Log(text);
             }
         }
     }
 }
Example #4
0
        public static void Unregister(Entity entity)
        {
            var tr = entity.Get <TransformComponent>();

            if (tr == null)
            {
                return;
            }
            tr.gameObject.GetComponentsInChildren(_tempIdentifiers);
            for (int i = 0; i < _tempIdentifiers.Count; i++)
            {
                if (_tempIdentifiers[i] == null)
                {
                    continue;
                }
                _tempIdentifiers[i].EntityID = -1;
            }
            tr.gameObject.GetComponentsInChildren(_tempColliders);
            for (int i = 0; i < _tempColliders.Count; i++)
            {
                if (_tempColliders[i] == null)
                {
                    continue;
                }
                _colliderToDictionary.Remove(_tempColliders[i]);
            }
            ItemPool.Despawn(tr.gameObject);
            entity.Remove <TransformComponent>();
        }
Example #5
0
 public void Reset()
 {
     FloatUpdate = null;
     IntUpdate   = null;
     V3Update    = null;
     ItemPool.Despawn(_text.gameObject);
 }
Example #6
0
 public void Clear()
 {
     for (int i = 0; i < _slots.Count; i++)
     {
         ItemPool.Despawn(_slots[i].gameObject);
     }
     _slots.Clear();
 }
 public void Dispose()
 {
     if (DebugObject != null)
     {
         ItemPool.Despawn(DebugObject);
         DebugObject = null;
     }
 }
Example #8
0
 private void ClearList()
 {
     for (int i = 0; i < CurrentRadials.Count; i++)
     {
         ItemPool.Despawn(CurrentRadials[i].gameObject);
     }
     CurrentRadials.Clear();
 }
Example #9
0
 private void ClearModList()
 {
     for (int i = 0; i < _active.Count; i++)
     {
         ItemPool.Despawn(_active[i].gameObject);
     }
     _active.Clear();
 }
Example #10
0
 public void Collision(Entity entity)
 {
     if (entity != null && entity.Tags.Contain(EntityTags.Player))
     {
         entity.Post(new HealingEvent(_amount, entity, entity, _vital));
         ItemPool.Despawn(gameObject);
     }
 }
 private void StartNewGame()
 {
     for (int i = _messages.Count - 1; i >= 0; i--)
     {
         ItemPool.Despawn(_messages[i].gameObject);
     }
     _messages.Clear();
 }
Example #12
0
        public void Collision(Entity hitEntity)
        {
            var template = hitEntity.GetTemplate <CharacterTemplate>();

            if (template != null && template.Tags.Contain(EntityTags.Player))
            {
                World.Get <RulesSystem>().Post(new HealingEvent(null, _amount, template, template, _vital));
                ItemPool.Despawn(gameObject);
            }
        }
Example #13
0
 private IEnumerator Despawn(float length)
 {
     _hideTween.Restart(_group.alpha, 0, length);
     while (_hideTween.Active)
     {
         _group.alpha = _hideTween.Get();
         yield return(null);
     }
     ItemPool.Despawn(gameObject);
 }
Example #14
0
        IEnumerator DespawnParticles()
        {
            yield return(MinimumSpawnTime);

            while (_particleSystem.IsAlive())
            {
                yield return(MinimumSpawnTime);
            }
            ItemPool.Despawn(gameObject);
        }
Example #15
0
 private void ClearTargetOptions()
 {
     MessageKit.post(Messages.OptionsChanged);
     _inputMapper.RemoveAllEventListeners();
     for (int i = 0; i < _targetOptions.Count; i++)
     {
         ItemPool.Despawn(_targetOptions[i]);
     }
     _targetOptions.Clear();
 }
        public void Handle(ReadyActionsChanged arg)
        {
            if (arg.Action == null)
            {
                return;
            }
            var weaponModelComponent = arg.Action.Weapon;

            if (weaponModelComponent == null)
            {
                if (arg.Container == null)
                {
                    arg.Action.Entity.Remove <SpawnPivotComponent>();
                }
                else
                {
                    var actionPivots = arg.Container.GetEntity().Get <ActionPivotsComponent>();
                    if (actionPivots != null)
                    {
                        arg.Action.Entity.Add(new SpawnPivotComponent(arg.Action.Config.Primary ? actionPivots.PrimaryPivot : actionPivots
                                                                      .SecondaryPivot));
                    }
                }
                return;
            }
            if (arg.Container == null)
            {
                ItemPool.Despawn(weaponModelComponent.Loaded.Tr.gameObject);
                arg.Action.Entity.Remove <TransformComponent>();
                arg.Action.Entity.Remove <SpawnPivotComponent>();
                weaponModelComponent.Set(null);
            }
            else
            {
                if (weaponModelComponent.Loaded != null)
                {
                    return;
                }
                var weaponModel = ItemPool.Spawn(UnityDirs.Weapons, weaponModelComponent.Prefab, Vector3.zero, Quaternion.identity, false,
                                                 false);
                if (weaponModel == null)
                {
                    return;
                }
                var projectileSpawn = arg.Container.GetEntity().Get <ActionPivotsComponent>();
                if (projectileSpawn != null)
                {
                    weaponModel.Transform.SetParentResetPos(arg.Action.Config.Primary? projectileSpawn.PrimaryPivot : projectileSpawn
                                                            .SecondaryPivot);
                }
                weaponModelComponent.Set(weaponModel.GetComponent <IWeaponModel>());
                arg.Action.Entity.Add(new TransformComponent(weaponModel.transform));
                arg.Action.Entity.Add(new SpawnPivotComponent(weaponModel.Transform));
            }
        }
Example #17
0
 private void OnStopped(InputMapper.StoppedEventData data)
 {
     UIModalQuestion.Stop();
     PlayerInput.AllInputBlocked = false;
     ReInput.userDataStore.Save();
     for (int i = 0; i < _targetOptions.Count; i++)
     {
         ItemPool.Despawn(_targetOptions[i]);
     }
     _targetOptions.Clear();
     RefreshControls();
 }
Example #18
0
        public static void RemovePermText(string label)
        {
            Text objText;

            if (!main._permTextDict.TryGetValue(label, out objText))
            {
                return;
            }
            ItemPool.Despawn(objText.gameObject);
            main._permTextDict[label] = null;
            main._permTextDict.Remove(label);
        }
Example #19
0
 void OnCollisionEnter(Collision collision)
 {
     if (collision.transform.CompareTag(StringConst.TagPlayer))
     {
         var entity = UnityToEntityBridge.GetEntity(collision.collider);
         if (entity != null)
         {
             entity.Post(new HealingEvent(_amount, entity, entity, _vital));
             ItemPool.Despawn(gameObject);
         }
     }
 }
Example #20
0
 void OnCollisionEnter(Collision collision)
 {
     if (collision.transform.CompareTag(StringConst.TagPlayer))
     {
         var entity = UnityToEntityBridge.GetEntity(collision.collider).GetTemplate <CharacterTemplate>();
         if (entity != null)
         {
             World.Get <RulesSystem>().Post(new HealingEvent(null, _amount, entity, entity, _vital));
             ItemPool.Despawn(gameObject);
         }
     }
 }
Example #21
0
 public IEnumerator SetTargetText(string text, float duration, Vector3 end, Color start)
 {
     _text.text  = text;
     _text.color = start;
     _moveTween.Restart(transform.position, end, duration);
     _colorTween.Restart(0, 1, duration);
     while (_moveTween.Active)
     {
         _text.color        = Color.Lerp(start, _endColor, _colorTween.Get());
         transform.position = _moveTween.Get();
         yield return(null);
     }
     ItemPool.Despawn(gameObject);
 }
Example #22
0
 public void ClearInventory()
 {
     if (_slots != null)
     {
         for (int i = 0; i < _slots.Length; i++)
         {
             if (_slots[i] == null)
             {
                 continue;
             }
             ItemPool.Despawn(_slots[i].gameObject);
         }
         _slots = null;
     }
 }
Example #23
0
        private IEnumerator CheckVisibleStatus()
        {
            yield return(_timeToDespawn);

            if (!_visible)
            {
                if (_despawnParent)
                {
                    ItemPool.Despawn(transform.parent.gameObject);
                }
                else
                {
                    ItemPool.Despawn(gameObject);
                }
            }
        }
Example #24
0
 public void TriggerSpawn(SpawnOnEvent spawnEvent, ActionEvent arg)
 {
     if (arg.State == spawnEvent.End && spawnEvent.ActiveGameObject != null)
     {
         ItemPool.Despawn(spawnEvent.ActiveGameObject);
     }
     else if (arg.State == spawnEvent.Start && spawnEvent.Prefab != null)
     {
         arg.GetSpawnPositionRotation(out var spawnPos, out var spawnRot);
         spawnEvent.ActiveGameObject = ItemPool.Spawn(spawnEvent.Prefab, spawnPos, spawnRot);
         if (spawnEvent.End == ActionState.None)
         {
             spawnEvent.ActiveGameObject = null;
         }
     }
 }
Example #25
0
 private void ClearSlots()
 {
     if (_slots == null)
     {
         return;
     }
     for (int i = 0; i < _slots.Length; i++)
     {
         if (_slots[i] == null)
         {
             continue;
         }
         ItemPool.Despawn(_slots[i].gameObject);
     }
     _slots = null;
 }
Example #26
0
 public IEnumerator SetTargetText(string text, float duration, Vector3 end, Color color)
 {
     _text.text  = text;
     _text.color = _defaultColor;
     _moveTween.Restart(transform.position, end, duration);
     _colorTween.Restart(0, 1, duration);
     while (_moveTween.Active)
     {
         _text.color        = Color.Lerp(_defaultColor, _endColor, _colorTween.Get());
         transform.position = _moveTween.Get();
         transform.LookAt(transform.position + Player.Cam.transform.rotation * Vector3.forward,
                          Player.Cam.transform.rotation * Vector3.up);
         //_text.fontSize = Vector3.Distance(transform.position, Player.Cam.transform.position) * 0.35f;
         yield return(null);
     }
     ItemPool.Despawn(gameObject);
 }
 private IEnumerator UpdateLight()
 {
     _light.enabled = true;
     while (!_lerp.IsFinished)
     {
         _light.intensity = _maxIntensity * _lightIntensity.Evaluate(_lerp.GetLerpValue());
         yield return(null);
     }
     if (_despawnOnComplete)
     {
         ItemPool.Despawn(gameObject);
     }
     else
     {
         _light.enabled = false;
     }
 }
Example #28
0
        private void HandleLoader(EquipmentChanged arg, ModelLoaderComponent loader)
        {
            if (!loader.OnlyActiveWhileEquipped)
            {
                return;
            }
            var entity = arg.Owner;

            if (arg.Owner == null && loader.LoadedComponents.Count > 0)
            {
                UnityToEntityBridge.Unregister(entity);
                for (int i = 0; i < loader.LoadedComponents.Count; i++)
                {
                    entity.Remove(loader.LoadedComponents[i]);
                }
                loader.LoadedComponents.Clear();
                loader.LoadedModel = null;
            }
            else if (arg.Owner != null && loader.LoadedModel == null)
            {
                var parent = arg.Slot.EquipTr;
                var model  = ItemPool.Spawn(loader.ModelName);
                if (parent != null)
                {
                    model.transform.SetParentResetPos(parent);
                }
                loader.LoadedModel = new CachedGenericComponent <IRenderingComponent>(model.GetComponent <IRenderingComponent>());
                if (loader.LoadedModel == null)
                {
                    ItemPool.Despawn(model.gameObject);
                    return;
                }

                UnityToEntityBridge.RegisterToEntity(model.gameObject, entity);
                loader.LoadedComponents.Add(entity.Add(new RenderingComponent(loader.LoadedModel.Value)).GetType());
                loader.LoadedComponents.Add(entity.Add(new TransformComponent(model.Transform)).GetType());
                loader.LoadedComponents.Add(
                    entity.Add(new FloatingTextStatusComponent(model.Transform, new Vector3(0, 1.5f, 0))).GetType());
                var rb = model.GetComponent <Rigidbody>();
                if (rb != null)
                {
                    loader.LoadedComponents.Add(entity.Add(new RigidbodyComponent(rb)).GetType());
                }
            }
        }
Example #29
0
 private void SetupRect()
 {
     if (_rect == null)
     {
         _rect = transform as RectTransform;
     }
     if (_rect == null)
     {
         Debug.LogErrorFormat("{0} {1} source {2} image tried to spawn as RecTransform but is not one", name, _animation != null ? _animation.name : "null", _image != null ? _image.name : "null");
         ItemPool.Despawn(gameObject);
         return;
     }
     _rect.anchorMin        = Vector2.zero;
     _rect.anchorMax        = Vector2.one;
     _rect.anchoredPosition = Vector2.zero;
     _rect.localScale       = Vector3.one;
     _rect.sizeDelta        = Vector2.zero;
 }
Example #30
0
 public void Play(SimpleAnimation anim, Material mat)
 {
     _animation = anim;
     if (_animation == null || _image == null)
     {
         ItemPool.Despawn(gameObject);
         return;
     }
     if (mat != null)
     {
         _image.material = mat;
     }
     if (transform.parent != null)
     {
         SetupRect();
     }
     Play();
 }