Пример #1
0
    public static MenuAction GetAction(string descr, Func <bool> del)
    {
        var newAction = _actionPool.New();

        newAction.Description = descr;
        newAction.Del         = del;
        return(newAction);
    }
Пример #2
0
        public void AddAnimation(SpriteAnimation animation, SpriteRenderer renderer, bool unscaled)
        {
            var node = _pool.New();

            node.Setup(renderer, animation, unscaled, TimeManager.Time);
            _current.Add(node);
        }
Пример #3
0
            public static void Start(Orientation type, string text, float duration, Vector3 start, Vector3 end, Transform parent, Color
                                     color, Sprite icon = null)
            {
                var txtHolder = _pool.New();

                txtHolder.Setup(LazyDb.Main.UIFloatingText[(int)type], text, duration, start, end, parent, color, icon);
            }
Пример #4
0
        public static RadialActionLayer Get(string descr, System.Action cancelDel)
        {
            var menuRequest = _actionPool.New();

            menuRequest.Description = descr;
            menuRequest.CancelDel   = cancelDel;
            return(menuRequest);
        }
Пример #5
0
 private EntityEventHub GetHub(int entity)
 {
     if (!_entityEvents.TryGetValue(entity, out var hub))
     {
         hub = _eventPool.New();
         _entityEvents.Add(entity, hub);
     }
     return(hub);
 }
Пример #6
0
        private void StartColorDamageTween(SpriteColorComponent colorComponent)
        {
            colorComponent.AnimatingColor = true;
            colorComponent.UpdateCurrentColor(Color.red);
            var tween = _floatPool.New();

            tween.Restart(1, colorComponent.DmgMaxScale);
            _colorList.Add(new SpriteColorWatch(colorComponent, tween, colorComponent.Renderer.transform.localScale));
        }
Пример #7
0
            public static void New(UIInventory inventory, Entity item, int index)
            {
                var loader = _pool.New();

                loader.SourcePrefab = LazyDb.Main.ItemDragDrop;
                loader._inventory   = inventory;
                loader._item        = item;
                loader._index       = index;
            }
Пример #8
0
        public static Flow New(GraphReference reference)
        {
            Ensure.That(nameof(reference)).IsNotNull(reference);

            var flow = GenericPool <Flow> .New(() => new Flow());;

            flow.stack = reference.ToStackPooled();

            return(flow);
        }
Пример #9
0
 private CachedEntity GetCachedEntity(Entity entity)
 {
     if (!_entityLookup.TryGetValue(entity, out var cached))
     {
         cached = _cachePool.New();
         cached.Set(entity);
         _entityLookup.Add(entity, cached);
     }
     return(cached);
 }
Пример #10
0
 private void SetupPoseTransition(MusclePose pose)
 {
     ClearSavedMuscles();
     for (int i = 0; i < pose.Pose.Count; i++)
     {
         var muscle      = _musclePool.New();
         var savedMuscle = pose.Pose[i];
         muscle.Set(savedMuscle, Animator.HumanPose.muscles[savedMuscle.MuscleIndex]);
         _currentMuscles.Add(muscle);
     }
 }
Пример #11
0
        public T Post <T>(T context) where T : struct, IRuleEvent
        {
            _eventLog.Add(context);
            var list = _listPool.New();

            _globalHandlers.TryGetValue(typeof(T), out var globalList);
            if (globalList != null)
            {
                list.AddRange(globalList);
            }
            if (context.Origin.RuleEvents != null)
            {
                list.AddRange(context.Origin.RuleEvents.Handlers);
            }
            if (context.Target != context.Origin && context.Target.RuleEvents != null)
            {
                list.AddRange(context.Target.RuleEvents.Handlers);
            }
            if (context.Action != null &&
                context.Action.RuleEvents != null)
            {
                list.AddRange(context.Action.RuleEvents.Handlers);
            }
            for (int i = 0; i < list.Count; i++)
            {
                if (list[i] is IRuleEventStart <T> startHandler)
                {
                    if (!startHandler.CanRuleEventStart(ref context))
                    {
                        _listPool.Store(list);
                        return(context);
                    }
                }
            }
            for (int i = 0; i < list.Count; i++)
            {
                if (list[i] is IRuleEventRun <T> handler)
                {
                    handler.RuleEventRun(ref context);
                }
            }
            for (int i = 0; i < list.Count; i++)
            {
                if (list[i] is IRuleEventEnded <T> endHandler)
                {
                    endHandler.RuleEventEnded(ref context);
                }
            }
            _listPool.Store(list);
            return(context);
        }
Пример #12
0
 private void PrepareTurn()
 {
     for (int i = 0; i < _queueActivate.Count; i++)
     {
         var node = _nodePool.New();
         node.Value = _queueActivate[i];
         _active.Add(node);
     }
     _queueActivate.Clear();
     for (int i = 0; i < _active.Count; i++)
     {
         _active[i].Priority = _active[i].Value.Speed;
     }
 }
Пример #13
0
        public static void SpawnProjectile(Entity owner, ProjectileConfig config, Vector3 target, Vector3 spawnPos, Quaternion spawnRot, ActionFx actionFx = null)
        {
            var entity = Main.GetProjectile(config);

            entity.ParentId = owner.Id;
            var projectileEvent = _loadPool.New();

            if (config.Type == ProjectileType.SpriteAnimation)
            {
                config.Animation.LoadAsset();
            }
            projectileEvent.Set(config, entity, target, spawnPos, spawnRot, actionFx);
            ItemPool.Spawn(projectileEvent);
        }
Пример #14
0
        private Task StartTaskInternal(IEnumerator routine, bool unscaled = false, System.Action del = null)
        {
            var task = _taskPool.New();

            task.Set(routine, unscaled);
            if (del != null)
            {
                task.OnFinish += del;
            }
            _active.Add(task);
#if UNITY_EDITOR
            if (!Application.isPlaying)
            {
                CheckEditor();
            }
#endif
            return(task);
        }
Пример #15
0
 private void SetWalkableInternal(Point3 pos, bool status)
 {
     if (!_cells.TryGetValue(pos, out var cell))
     {
         cell      = _cellPool.New();
         cell.Cost = _defaultCost;
         _cells.Add(pos, cell);
         _cellKeys.Add(pos);
     }
     if (status)
     {
         cell.Flags |= CellWalkable;
     }
     else
     {
         cell.Flags &= ~CellWalkable;
     }
     CellsCount = _cells.Count;
 }
Пример #16
0
        public static UnitPreservation Preserve(IUnit unit)
        {
            var preservation = GenericPool <UnitPreservation> .New(() => new UnitPreservation());

            foreach (var defaultValue in unit.defaultValues)
            {
                preservation.defaultValues.Add(defaultValue.Key, defaultValue.Value);
            }

            foreach (var input in unit.inputs)
            {
                if (input.hasAnyConnection)
                {
                    preservation.inputConnections.Add(input.key, ListPool <UnitPortPreservation> .New());

                    foreach (var connectedPort in input.connectedPorts)
                    {
                        preservation.inputConnections[input.key].Add(new UnitPortPreservation(connectedPort));
                    }
                }
            }

            foreach (var output in unit.outputs)
            {
                if (output.hasAnyConnection)
                {
                    preservation.outputConnections.Add(output.key, ListPool <UnitPortPreservation> .New());

                    foreach (var connectedPort in output.connectedPorts)
                    {
                        preservation.outputConnections[output.key].Add(new UnitPortPreservation(connectedPort));
                    }
                }
            }

            return(preservation);
        }
Пример #17
0
            public static void Start(GameObjectReference prefab, string text, float duration, Vector3 start, Vector3 end, Color?color)
            {
                var txtHolder = _pool.New();

                txtHolder.Setup(prefab, text, duration, start, end, color);
            }