public static void EvaluateList(Translation translation,
                                    AlertRange alertRange,
                                    NativeArray <Entity> entities,
                                    NativeArray <Translation> positions,
                                    Entity entity,
                                    int entityIndex,
                                    EntityCommandBuffer.Concurrent ECB)
    {
        float closestSqDistance = alertRange.Range * alertRange.Range;

        bool   targetFound = false;
        Entity target      = Entity.Null;

        for (int i = 0; i < entities.Length; i++)
        {
            //check the squared distance to this Player and see if it's under the closest one we already found
            float currentSqDistance = math.lengthsq(positions[i].Value - translation.Value);
            if (currentSqDistance < closestSqDistance)
            {
                target            = entities[i];
                closestSqDistance = currentSqDistance;
                targetFound       = true;
            }
        }

        if (targetFound)
        {
            ECB.AddComponent <Target>(entityIndex, entity, new Target {
                Entity = target
            });
        }
    }
        public override Dictionary <string, object> SaveToDict()
        {
            var dict = new Dictionary <string, object>();

            dict.Add(GDMConstants.SchemaKey, "Enemy");

            dict.Merge(true, ID.ToGDEDict(IDKey));
            dict.Merge(true, MaxHP.ToGDEDict(MaxHPKey));
            dict.Merge(true, MoveVec.ToGDEDict(MoveVecKey));
            dict.Merge(true, AlertRange.ToGDEDict(AlertRangeKey));
            dict.Merge(true, AtkRange.ToGDEDict(AtkRangeKey));
            dict.Merge(true, AtkInterval.ToGDEDict(AtkIntervalKey));
            dict.Merge(true, HurtProtect.ToGDEDict(HurtProtectKey));
            dict.Merge(true, Mass.ToGDEDict(MassKey));
            dict.Merge(true, PrefabPath.ToGDEDict(PrefabPathKey));
            return(dict);
        }
Beispiel #3
0
        public override Dictionary <string, object> SaveToDict()
        {
            var dict = new Dictionary <string, object>();

            dict.Add(GDMConstants.SchemaKey, "Weapon");

            dict.Merge(true, ID.ToGDEDict(IDKey));
            dict.Merge(true, MagazineSize.ToGDEDict(MagazineSizeKey));
            dict.Merge(true, ConsumePerHit.ToGDEDict(ConsumePerHitKey));
            dict.Merge(true, DamageVal.ToGDEDict(DamageValKey));
            dict.Merge(true, AtkInterval.ToGDEDict(AtkIntervalKey));
            dict.Merge(true, ChargeTime.ToGDEDict(ChargeTimeKey));
            dict.Merge(true, ReloadTime.ToGDEDict(ReloadTimeKey));
            dict.Merge(true, Thrust.ToGDEDict(ThrustKey));
            dict.Merge(true, AlertRange.ToGDEDict(AlertRangeKey));
            dict.Merge(true, PrefabPath.ToGDEDict(PrefabPathKey));
            dict.Merge(true, SkinName.ToGDEDict(SkinNameKey));

            dict.Merge(true, OpaType.ToGDEDict(OpaTypeKey));
            dict.Merge(true, AniType.ToGDEDict(AniTypeKey));
            return(dict);
        }
Beispiel #4
0
 public IEnumerable <(DateTime, DateTime?)> GetEffectiveTimeRange(DateTime today, AlertRange range)
 {
     if (range is OnceAlertRange once && once.StartTimestamp.Date == today)
     {
         yield return(once.StartTimestamp, once.EndTimestamp);
     }