public void ClearOrder() { if (ordersForLaterTurn.Ptr == null) { return; } UnsafeUtility.Free(ordersForLaterTurn.Ptr, Allocator.Persistent); ordersForLaterTurn = default; ordersForLaterTurnCount = default; }
public Turn(TurnId turnId, Board board, NativeEnumerable <Power> powers, NativeEnumerable <EnergySupplier> energySuppliers, uint randomSeed) { this.TurnId = turnId; this.Board = board; this.Powers = powers; this.EnergySuppliers = energySuppliers; RandomSeed = randomSeed; this.ordersForLaterTurn = default; this.ordersForLaterTurnCount = default; }
/// <inheritdoc /> protected override INetFwAuthorizedApplication InternalItem(string key) { try { return(NativeEnumerable.Item(key)); } catch (FileNotFoundException) { return(null); } }
/// <inheritdoc /> protected override INetFwProduct InternalItem(int key) { try { return(NativeEnumerable.Item(key)); } catch (FileNotFoundException) { return(null); } }
/// <inheritdoc /> protected override INetFwOpenPort InternalItem(FirewallLegacyPortCollectionKey key) { try { return(NativeEnumerable.Item(key.PortNumber, key.ProtocolType)); } catch (FileNotFoundException) { return(null); } }
/// <inheritdoc /> protected override INetFwService InternalItem(NET_FW_SERVICE_TYPE key) { try { return(NativeEnumerable.Item(key)); } catch (FileNotFoundException) { return(null); } }
public void ProcessOrderCollection(GameMasterData *master, Turn *turn, NativeEnumerable <Order> orders) { new LivingJob(master, turn).Execute(); new OrderJob(master, turn, orders).Execute(); new GenerateJob(master, turn).Execute(); new AdvanceJob(master, turn).Execute(); new PaintJob(master, turn).Execute(); new EatingJob(master, turn).Execute(); new RenewLockOnJob(master, turn).Execute(); new BattleJob(master, turn).Execute(); turn->ReFillEnergySuppliers(ref *master); }
/// <summary> /// Returns the flag whether the value exists as the value element of a pre-declared property. Not /// sure who would use this, but its there, with a default implementation. /// </summary> /// <param name="value">property value</param> /// <returns>flag</returns> public virtual bool NativeContainsValue(object value) { using var enumerator = NativeEnumerable.GetEnumerator(); while (enumerator.MoveNext()) { if (Equals(value, enumerator.Current.Value)) { return(true); } } return(false); }
public GameMasterData(int speciesTypeCount, int unitTypeCount, int cellTypeCount, int width, int height, int maxPowerCount, uint energySupplierCount, uint maxTurnCount, NativeEnumerable <UnitInitialHp> initialHpTable, NativeEnumerable <UnitMaxHp> maxHpTable, NativeEnumerable <UnitMovePower> movePowerTable, NativeEnumerable <UnitPaintCost> paintCostTable, NativeEnumerable <UnitPaintPoint> paintPointTable, NativeEnumerable <UnitPaintInterval> paintIntervalTable, NativeEnumerable <UnitGenerationCost> generationCostTable, NativeEnumerable <UnitGenerationInterval> generationIntervalTable, NativeEnumerable <UnitGenerationRequiredHp> generationRequiredHpTable, NativeEnumerable <UnitAttackPoint> attackPointTable, NativeEnumerable <UnitAttackCost> attackCostTable, NativeEnumerable <UnitAttackInterval> attackIntervalTable, NativeEnumerable <UnitAttackRange> attackRangeTable, NativeEnumerable <UnitLivingCost> livingCostTable, NativeEnumerable <UnitLivingInterval> livingIntervalTable, NativeEnumerable <CellMoveCost> cellMoveCostTable, NativeEnumerable <UnitViewRange> viewRangeTable) { this.speciesTypeCount = speciesTypeCount; this.unitTypeCount = unitTypeCount; this.cellTypeCount = cellTypeCount; this.initialHpTable = initialHpTable; this.movePowerTable = movePowerTable; this.maxHpTable = maxHpTable; this.paintCostTable = paintCostTable; this.paintPointTable = paintPointTable; this.paintIntervalTable = paintIntervalTable; this.generationCostTable = generationCostTable; this.generationIntervalTable = generationIntervalTable; this.generationRequiredHpTable = generationRequiredHpTable; this.attackPointTable = attackPointTable; this.attackCostTable = attackCostTable; this.attackIntervalTable = attackIntervalTable; this.attackRangeTable = attackRangeTable; this.livingCostTable = livingCostTable; this.livingIntervalTable = livingIntervalTable; this.cellMoveCostTable = cellMoveCostTable; this.viewRangeTable = viewRangeTable; MaxTurnCount = maxTurnCount; Width = width; Height = height; MaxPowerCount = maxPowerCount; EnergySupplierCount = energySupplierCount; }
public void AddOrder(Order order) { if (ordersForLaterTurn.Ptr == null) { ordersForLaterTurn = NativeEnumerable <Order> .Create(UnsafeUtilityEx.Malloc <Order>(16, Allocator.Persistent), 16); UnsafeUtility.MemClear(ordersForLaterTurn.Ptr + 1, 15 * sizeof(Order)); } else if (ordersForLaterTurnCount == ordersForLaterTurn.Length) { var newEnumerable = NativeEnumerable <Order> .Create(UnsafeUtilityEx.Malloc <Order>(ordersForLaterTurnCount << 1, Allocator.Persistent), ordersForLaterTurnCount << 1); UnsafeUtilityEx.MemCpy(newEnumerable.Ptr, ordersForLaterTurn.Ptr, ordersForLaterTurnCount); UnsafeUtility.MemClear(newEnumerable.Ptr + ordersForLaterTurnCount + 1, (ordersForLaterTurnCount - 1) * sizeof(Order)); ordersForLaterTurn.Dispose(Allocator.Persistent); ordersForLaterTurn = newEnumerable; } ordersForLaterTurn[ordersForLaterTurnCount++] = order; }
public Board(int2 size) { var count = size.x * size.y; #if DEBUG if (math.any(size < 0)) { throw new ArgumentOutOfRangeException(size.x + ", " + size.y + " should not be less than 0!"); } #endif if (math.any(size == 0)) { Cells = default; return; } Cells = NativeEnumerable <Cell> .Create(UnsafeUtilityEx.Malloc <Cell>(count, Allocator.Persistent), count); UnsafeUtility.MemClear(Cells.Ptr, count * sizeof(Cell)); }
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); }
/// <inheritdoc /> protected override INetFwAuthorizedApplication InternalItem(string key) { return(NativeEnumerable.Item(key)); }
/// <inheritdoc /> protected override IEnumVARIANT GetEnumVariant() { return(NativeEnumerable.GetEnumeratorVariant()); }
/// <inheritdoc /> protected override void InternalAdd(INetFwRule native) { NativeEnumerable.Add(native); }
/// <inheritdoc /> protected override INetFwRule InternalItem(string key) { return(NativeEnumerable.Item(key)); }
/// <inheritdoc /> protected override INetFwOpenPort InternalItem(FirewallLegacyPortCollectionKey key) { return(NativeEnumerable.Item(key.PortNumber, key.ProtocolType)); }
/// <inheritdoc /> protected override INetFwService InternalItem(NET_FW_SERVICE_TYPE key) { return(NativeEnumerable.Item(key)); }
/// <inheritdoc /> protected override void InternalRemove(string key) { NativeEnumerable.Remove(key); }
/// <inheritdoc /> protected override INetFwService InternalItem(NetFwServiceType key) { return(NativeEnumerable.Item(key)); }
/// <inheritdoc /> protected override INetFwProduct InternalItem(int key) { return(NativeEnumerable.Item(key)); }
static void SwapBack <T>(NativeEnumerable <T> array, int i, int end) where T : unmanaged { array[i] = array[end]; }
/// <inheritdoc /> protected override void InternalAdd(INetFwOpenPort native) { NativeEnumerable.Add(native); }
/// <inheritdoc /> protected override void InternalAdd(INetFwAuthorizedApplication native) { NativeEnumerable.Add(native); }
/// <inheritdoc /> protected override void InternalRemove(FirewallLegacyPortCollectionKey key) { NativeEnumerable.Remove(key.PortNumber, key.ProtocolType); }
public OrderJob(GameMasterData *master, Turn *turn, NativeEnumerable <Order> orders) { this.master = master; this.turn = turn; this.orders = orders.Where(new TurnIdEquality(turn->TurnId)); }