Beispiel #1
0
        public Power(PowerId powerId, int capacity)
        {
            if (capacity < 0)
            {
                throw new ArgumentOutOfRangeException(capacity + " should not be less than 0!");
            }
            if (capacity == 0)
            {
                this    = default;
                PowerId = powerId;
                return;
            }
            PowerId         = powerId;
            knownPowerFlags = 1U << (int)powerId.Value;
            NextUnitId      = default;
            TeamCount       = default;
            SpeciesTypes    = NativeEnumerable <SpeciesType> .Create((SpeciesType *)Malloc(capacity), capacity);

            UnsafeUtility.MemClear(SpeciesTypes.Ptr, CalcCapacityByteLength(capacity));
            UnitIds = NativeEnumerable <UnitId> .Create((UnitId *)(SpeciesTypes.Ptr + capacity), capacity);

            UnitTypes = NativeEnumerable <UnitType> .Create((UnitType *)(UnitIds.Ptr + capacity), capacity);

            InitialCounts = NativeEnumerable <UnitInitialCount> .Create((UnitInitialCount *)(UnitTypes.Ptr + capacity), capacity);

            TotalHps = NativeEnumerable <UnitTotalHp> .Create((UnitTotalHp *)(InitialCounts.Ptr + capacity), capacity);

            Statuses = NativeEnumerable <UnitStatus> .Create((UnitStatus *)(TotalHps.Ptr + capacity), capacity);

            Positions = NativeEnumerable <UnitPosition> .Create((UnitPosition *)(Statuses.Ptr + capacity), capacity);

            MovePowers = NativeEnumerable <UnitMovePower> .Create((UnitMovePower *)(Positions.Ptr + capacity), capacity);

            Destinations = NativeEnumerable <UnitDestination> .Create((UnitDestination *)(MovePowers.Ptr + capacity), capacity);

            MiscellaneousData = NativeEnumerable <ulong> .Create((ulong *)(Destinations.Ptr + capacity), capacity);

            MiscellaneousData2 = NativeEnumerable <ulong> .Create((ulong *)(MiscellaneousData.Ptr + capacity), capacity);

            GenerationTurns = NativeEnumerable <TurnId> .Create((TurnId *)(MiscellaneousData2.Ptr + capacity), capacity);
        }
Beispiel #2
0
 public ref                               Power this[PowerId id] => ref Powers[id.Value];