Exemple #1
0
        public void Del(IShieldField field)
        {
            switch (field)
            {
            case LinearShieldLink link:
                _linearLinks.Remove(link);
                break;

            default:
                _fields.Remove(field);
                break;
            }
        }
Exemple #2
0
        public void Add(IShieldField field)
        {
            switch (field)
            {
            case LinearShieldLink link:
                _linearLinks.Add(link);
                break;

            default:
                _fields.Add(field);
                break;
            }
        }
Exemple #3
0
        private static bool Impact(ProjectileCE projectile, IShieldField shield, Vector3 position)
        {
            var traverse              = new Traverse(projectile);
            var ticksToImpact         = traverse.Field("ticksToImpact");
            var startingTicksToImpact = traverse.Property("StartingTicksToImpact").GetValue <float>();

            // rewind the projectile 1 tick to get the last position before the CheckForCollisionBetween we are in
            ticksToImpact.SetValue(ticksToImpact.GetValue <int>() + 1);

            while (shield.Collision(projectile.ExactPosition.Yto0()))
            {
                var amount = ticksToImpact.GetValue <int>();
                if (amount > startingTicksToImpact)
                {
                    Log.Message("Unable to find good place to detonate " + projectile.ThingID + ", destroying without detonating");
                    return(false);
                }
                ticksToImpact.SetValue(amount + 1);
            }
            impactMethod.Invoke(projectile, new object[] { null });
            return(true);
        }
 public abstract void Del(IShieldField field);
 public abstract void Add(IShieldField field);
Exemple #6
0
 public static bool HostileTo(IShieldField shield, Faction faction, bool invert = false)
 {
     return((shield.Faction != faction &&
             shield.Faction.RelationKindWith(faction) == FactionRelationKind.Hostile)
            != invert);
 }
Exemple #7
0
 public static bool FriendlyTo(IShieldField shield, Faction faction, bool invert = false)
 {
     return((shield.Faction == faction ||
             shield.Faction.RelationKindWith(faction) == FactionRelationKind.Ally)
            != invert);
 }
Exemple #8
0
 public static bool OfFaction(IShieldField shield, Faction faction, bool invert = false)
 {
     return(shield.Faction == faction != invert);
 }
Exemple #9
0
 public static bool IsActive(IShieldField shield, bool isActive = true)
 {
     return(shield.IsActive() == isActive);
 }
Exemple #10
0
 public static IShieldManager For(IShieldField shield)
 {
     return(For(shield.Map, false));
 }
Exemple #11
0
 public IEnumerable <Map> PresentOnMaps(IShieldField field)
 {
     return(_associated.Where(field.PresentOnMap));
 }
 private static bool Impact(Projectile projectile, IShieldField shield, Vector3 point)
 {
     impactMethod.Invoke(projectile, new object[] { null });
     return(true);
 }