Exemplo n.º 1
0
        public void CastGroundTarget(Vector3 worldPos)
        {
            var origin      = Self.transform.position;
            var boxBaseSize = new Vector2(_pathWidth, 2);
            var length      = AbilityHelper.GetLineLength(origin, worldPos);

            length = Mathf.Min(length, CurrentCastRange);
            var boxHalfExtents = new Vector3(boxBaseSize.x, boxBaseSize.y, length) / 2;
            var rotation       = AbilityHelper.GetRotation(origin, worldPos);
            var center         = AbilityHelper.GetBoxCenter(origin, boxHalfExtents, rotation);
            var colliders      = Physics.OverlapBox(center, boxHalfExtents, rotation, (int)LayerMaskFlag.Entity);
            var dmg            = new Damage(_damage, DamageType.Magical, DamageFlags.Ability);

            foreach (var col in colliders)
            {
                if (!AbilityHelper.TryGetActor(col, out var actor))
                {
                    continue; //Not an actor, ignore
                }
                if (!CheckBuilder.AllowTarget(actor))
                {
                    continue; //Ignore if allies
                }
                if (!actor.TryGetModule <IDamageable>(out var damageTarget))
                {
                    continue; //Ignore if cant damage
                }
                damageTarget.TakeDamage(Self, dmg);
            }
        }
Exemplo n.º 2
0
        public void CastNoTarget()
        {
            //TODO channel

            var targets = Physics.OverlapSphere(Self.transform.position, _aoeSearchRange, (int)LayerMaskFlag.Entity);

            var damage = new Damage(_aoeDamage, DamageType.Magical, DamageFlags.Ability);

            foreach (var target in targets)
            {
                if (!AbilityHelper.TryGetActor(target, out var actor))
                {
                    continue;
                }
                if (!CheckBuilder.AllowTarget(actor))
                {
                    continue;
                }

                if (!actor.TryGetModule <IDamageable>(out var damageTarget))
                {
                    continue;
                }

                damageTarget.TakeDamage(Self, damage);
            }
        }
Exemplo n.º 3
0
        public override void ConfirmCast()
        {
            if (!AbilityHelper.TryRaycastActor(out var actor))
            {
                return;
            }

            if (!CheckBuilder.AllowCast())
            {
                return;
            }
            if (!CheckBuilder.AllowTarget(actor))
            {
                return;
            }

            if (actor.TryGetModule <ITargetable>(out var targetable))
            {
                if (!targetable.AllowSpellTargets)
                {
                    return;
                }
            }
            if (!AbilityHelper.HasModule <IDamageable>(actor.gameObject))
            {
                return;
            }

            CheckBuilder.DoCast();

            Cast(Self, actor);
            Modules.Abilitiable.NotifyAbilityCast(new AbilityEventArgs(Self, View.StatCost.Cost));
        }
Exemplo n.º 4
0
#pragma warning restore 0649


        public override void ConfirmCast()
        {
            if (Active)
            {
                return;
            }

            if (!CheckBuilder.AllowCast())
            {
                return;
            }

            Active = true;
            _channelTimer.Reset();
            CheckBuilder.MagicCost.SpendCost();
            CastNoTarget();
            Modules.Abilitiable.NotifyAbilityCast(new AbilityEventArgs(Self, CheckBuilder.MagicCost.Cost));
        }
Exemplo n.º 5
0
        public override void ConfirmCast()
        {
            var ray = AbilityHelper.GetScreenRay();

            if (!AbilityHelper.TryGetWorld(ray, out var hit))
            {
                return;
            }
            if (!CheckBuilder.AllowCast())
            {
                return;
            }
            CastRange.MaxDistance = _overheat.Active ? _overheatCastRange : _castRange;
            if (!CastRange.InRange(hit.point))
            {
                return;
            }
            CheckBuilder.DoCast();
            CastGroundTarget(hit.point);
            Modules.Abilitiable.NotifyAbilityCast(new AbilityEventArgs(Self, View.StatCost.Cost));
        }
Exemplo n.º 6
0
        public Either <Error, Void> AddToken(Biscuit token, Option <PublicKey> root)
        {
            if (!token.IsSealed())
            {
                Either <Error, Void> res = token.CheckRootKey(root.Get());
                if (res.IsLeft)
                {
                    return(res.Left);
                }
            }

            if (this.token != null)
            {
                return(new FailedLogic(new LogicError.VerifierNotEmpty()));
            }

            ulong authority_index = symbols.Get("authority").Get();
            ulong ambient_index   = symbols.Get("ambient").Get();

            foreach (Fact fact in token.Authority.Facts)
            {
                if (fact.Predicate.Ids[0].Equals(new ID.Symbol(ambient_index)))
                {
                    return(new FailedLogic(new LogicError.InvalidAuthorityFact(symbols.PrintFact(fact))));
                }

                Fact converted_fact = FactBuilder.ConvertFrom(fact, token.Symbols).Convert(this.symbols);
                world.AddFact(converted_fact);
            }

            foreach (Rule rule in token.Authority.Rules)
            {
                Rule converted_rule = RuleBuilder.ConvertFrom(rule, token.Symbols).Convert(this.symbols);
                world.AddPrivilegedRule(converted_rule);
            }

            List <Check> authority_checks = new List <Check>();

            foreach (Check check in token.Authority.Checks)
            {
                Datalog.Check converted_check = CheckBuilder.ConvertFrom(check, token.Symbols).Convert(this.symbols);
                authority_checks.Add(converted_check);
            }
            token_checks.Add(authority_checks);

            for (int i = 0; i < token.Blocks.Count; i++)
            {
                Block b = token.Blocks[i];
                if (b.Index != i + 1)
                {
                    return(new InvalidBlockIndex(1 + token.Blocks.Count, token.Blocks[i].Index));
                }

                foreach (Fact fact in b.Facts)
                {
                    if (fact.Predicate.Ids[0].Equals(new ID.Symbol(authority_index)) ||
                        fact.Predicate.Ids[0].Equals(new ID.Symbol(ambient_index)))
                    {
                        return(new FailedLogic(new LogicError.InvalidBlockFact(i, symbols.PrintFact(fact))));
                    }

                    Fact converted_fact = FactBuilder.ConvertFrom(fact, token.Symbols).Convert(this.symbols);
                    world.AddFact(converted_fact);
                }

                foreach (Rule rule in b.Rules)
                {
                    Rule converted_rule = RuleBuilder.ConvertFrom(rule, token.Symbols).Convert(this.symbols);
                    world.AddRule(converted_rule);
                }

                List <Check> block_checks = new List <Check>();
                foreach (Check check in b.Checks)
                {
                    Check converted_check = CheckBuilder.ConvertFrom(check, token.Symbols).Convert(this.symbols);
                    block_checks.Add(converted_check);
                }
                token_checks.Add(block_checks);
            }

            List <RevocationIdentifier> revocation_ids = token.RevocationIdentifiers;
            ulong rev = symbols.Get("revocation_id").Get();

            for (int i = 0; i < revocation_ids.Count; i++)
            {
                byte[] id = revocation_ids[i].Bytes;
                world.AddFact(new Fact(new Predicate(rev, Arrays.AsList <ID>(new ID.Integer(i), new ID.Bytes(id)))));
            }

            return(new Right(null));
        }
Exemplo n.º 7
0
 public void AddCheck(CheckBuilder check)
 {
     this.checks.Add(check);
     world.AddCheck(check.Convert(symbols));
 }
Exemplo n.º 8
0
        public void CastObjectTarget(Actor target)
        {
            //Deal damage
            var damage = new Damage(_damage, DamageType.Magical, DamageFlags.Ability);
//            var targetable = target.GetComponent<ITargetable>();
            var damagable = target.GetModule <IDamageable>();

            damagable.TakeDamage(Self, damage);
            //Gather DOT targets
            var dotTargets = new List <Actor> {
                target
            };

            if (IsInOverheat)
            {
                var colliders = Physics.OverlapSphere(target.transform.position, _overheatSearchRange,
                                                      (int)LayerMaskFlag.Entity);
                foreach (var collider in colliders)
                {
                    if (!AbilityHelper.TryGetActor(collider, out var actor))
                    {
                        continue;
                    }
                    if (!CheckBuilder.AllowTarget(actor))
                    {
                        continue;
                    }
                    if (actor == target) //Already added
                    {
                        continue;
                    }
                    dotTargets.Add(actor);
                }
            }

            foreach (var actor in dotTargets)
            {
                if (!actor.TryGetModule <IDamageable>(out var damageTarget))
                {
                    continue;
                }
                var source    = Self;
                var dotDamage = new Damage(_tickDamage, DamageType.Magical, DamageFlags.Ability);

                void internalFunc()
                {
                    damageTarget.TakeDamage(source, dotDamage);
                }

                var tickWrapper = new TickAction
                {
                    Callback     = internalFunc,
                    TickCount    = _tickCount,
                    TickInterval = _tickInterval
                };

                if (actor.TryGetModule <IKillable>(out var killable))
                {
                    killable.Died += RemoveTick;
                }

                void RemoveTick(object sender, DeathEventArgs args)
                {
                    killable.Died -= RemoveTick;
                    _ticks.Remove(tickWrapper);
                }

                _ticks.Add(tickWrapper);
                ApplyFX(actor.transform, _tickCount * _tickInterval);
            }
        }