public override IEnumerable <IModdable> GetPotentialBroadcastTargets()
        {
            List <IModdable> moddables = new List <IModdable>();
            IModdable        self      = GetComponent <IModdable>();

            if (ProvideUpwards == ProvideBehaviour.All)
            {
                IEnumerable <IModdable> upwards = GetComponentsInParent <IModdable>().Where(x => x != self);
                moddables.AddRange(upwards);
            }
            else if (ProvideUpwards == ProvideBehaviour.Single)
            {
                moddables.Add(GetComponentInParent <IModdable>());
            }

            if (ProvideDownwards == ProvideBehaviour.All)
            {
                IEnumerable <IModdable> upwards = GetComponentsInChildren <IModdable>().Where(x => x != self);
                moddables.AddRange(upwards);
            }
            else if (ProvideDownwards == ProvideBehaviour.Single)
            {
                moddables.Add(GetComponentInChildren <IModdable>());
            }

            if (ProvideSelf)
            {
                moddables.Add(self);
            }

            return(moddables);
        }
Exemplo n.º 2
0
 private void RemoveMod(IModdable moddable)
 {
     if (moddable != null)
     {
         moddable.Mods.RemoveMod(Mod.Identifier);
     }
 }
Exemplo n.º 3
0
 public bool ToPosition(Vector2 position, Quaternion rotation)
 {
     focusModdable      = null;
     transform.position = position;
     transform.rotation = rotation;
     return(true);
 }
 public bool Check(IModdable moddable)
 {
     if (moddable is IIdentifiable identifiable)
     {
         return(identifiable.Identifier == Identiifier);
     }
     return(false);
 }
Exemplo n.º 5
0
 public bool Check(IModdable moddable)
 {
     if (moddable is Structure structure)
     {
         return(Check(structure));
     }
     return(false);
 }
Exemplo n.º 6
0
 public override bool CanMod(IModdable moddable)
 {
     if (Filters != null && Filters.Length > 0)
     {
         return(Filters.All(x => x.Check(moddable)));
     }
     return(true);
 }
Exemplo n.º 7
0
 public bool Check(IModdable moddable)
 {
     if (moddable is ITagged tagged)
     {
         return(Tags.All(x => tagged.HasTag(x)));
     }
     return(false);
 }
Exemplo n.º 8
0
 private bool AddMod(IModdable moddable)
 {
     if (Mod.CanMod(moddable))
     {
         moddable.Mods.AddMod(Instantiate(Mod));
         return(true);
     }
     return(false);
 }
Exemplo n.º 9
0
        public bool ToTransforms(Transform[] transforms)
        {
            IEnumerable <IModdable> moddableList = transforms.Select(x => x.GetComponent <IModdable>());

            IModdable[] moddables = moddableList.Where(x => _modifier.IsComptabible(x)).ToArray();

            if (moddables.Length > 0)
            {
                focusModdable = moddables[Mathf.Abs(_focusIndex % moddables.Length)];
                return(true);
            }
            return(false);
        }
Exemplo n.º 10
0
        private void RemoveMods()
        {
            IModdable target = GetTarget();

            if (target != null)
            {
                foreach (var provider in GetProviders())
                {
                    target.Mods.RemoveMod(provider.Mod.Identifier);
                    provider.EnableComponents();
                }
            }
        }
Exemplo n.º 11
0
        private void ApplyMods()
        {
            IModdable target = GetTarget();

            if (target != null)
            {
                foreach (var provider in GetProviders())
                {
                    target.Mods.AddMod(provider.Mod);
                    provider.DisableComponents();
                }
            }
        }
Exemplo n.º 12
0
 public override IEnumerable <IModdable> GetPotentialBroadcastTargets()
 {
     foreach (Transform sibling in GetSiblings())
     {
         if (IsAdjecent(sibling.gameObject))
         {
             IModdable moddable = sibling.GetComponent <IModdable>();
             if (moddable != null && Mod.CanMod(moddable))
             {
                 yield return(moddable);
             }
         }
     }
 }
Exemplo n.º 13
0
 private IModdable GetTarget()
 {
     foreach (Transform child in transform)
     {
         if (IsTargetPosition(child.localPosition))
         {
             IModdable moddable = child.GetComponent <IModdable>();
             if (moddable != null)
             {
                 return(moddable);
             }
         }
     }
     return(null);
 }
Exemplo n.º 14
0
        public override void RemoveEffect(IModdable target)
        {
            IStatContainer container = target as IStatContainer;
            Stat           stat      = container.GetStat(Identifier);

            switch (Type)
            {
            case StatType.Additive:
                stat.RemoveAdditive(this);
                break;

            case StatType.Multiplicative:
                stat.RemoveMultiplicative(this);
                break;
            }
        }
Exemplo n.º 15
0
        public override void ApplyEffect(IModdable target)
        {
            _target = target;
            IStatContainer container = target as IStatContainer;
            Stat           stat      = container.GetStat(Identifier);

            //TODO: Consider having StatType be a member of Stat instead of StatMod, then handling how to add the stat in Stat.
            switch (Type)
            {
            case StatType.Additive:
                stat.AddAdditive(Value.Get() * Coeffecient.Get(), this);
                break;

            case StatType.Multiplicative:
                stat.AddMultiplicative(Value.Get() * Coeffecient.Get(), this);
                break;
            }
        }
Exemplo n.º 16
0
 public bool Check(IModdable moddable)
 {
     return(Filters.Any(x => x.Check(moddable)));
 }
Exemplo n.º 17
0
 public abstract void OnRemove(IModdable moddable);
Exemplo n.º 18
0
 public override void OnRemove(IModdable moddable)
 {
     moddable.ResetDash();
 }
Exemplo n.º 19
0
 public abstract void OnApply(IModdable moddable);
Exemplo n.º 20
0
 public override void OnRemove(IModdable moddable)
 {
     moddable.ResetSize();
 }
Exemplo n.º 21
0
 public static void RemoveMod(Mod mod, IModdable moddable)
 {
     mod.RemoveEffect(moddable);
 }
Exemplo n.º 22
0
 public abstract void RemoveEffect(IModdable target);
Exemplo n.º 23
0
 public abstract void ApplyEffect(IModdable target);
Exemplo n.º 24
0
 public virtual bool IsCompatible(IModdable target)
 {
     Tag[] targetTags = target.GetModTags();
     return(targetTags.Contains(ModTag));
 }
Exemplo n.º 25
0
 public static void ApplyMod(Mod mod, IModdable moddable)
 {
     mod.ApplyEffect(moddable);
 }
Exemplo n.º 26
0
 public override void OnApply(IModdable moddable)
 {
     moddable.SetSpeed(reductionPercentage);
 }
Exemplo n.º 27
0
 public override void OnApply(IModdable moddable)
 {
     moddable.SetSize(incrementPercentage);
 }
        public override void RemoveEffect(IModdable target)
        {
            IEventContainer container = target as IEventContainer;

            container.GetEvent(Event).Detach(Handler);
        }
Exemplo n.º 29
0
 public abstract bool CanMod(IModdable moddable);
Exemplo n.º 30
0
 public bool Check(IModdable moddable)
 {
     return(!ToInvert.Check(moddable));
 }