public UnitList(AEmpire theEmpire) { TheEmpire = theEmpire; EmpirePtr = theEmpire.Data; UnitsPtr = EmpirePtr->UnitsData; theEmpire.OnStartOfTurnOrResume += Refresh; }
public CityList(AEmpire theEmpire) { TheEmpire = theEmpire; EmpirePtr = theEmpire.Data; CitiesPtr = EmpirePtr->CitiesData; theEmpire.OnStartOfTurnOrResume += Refresh; }
/// <summary> /// Create general unit movement iterator for an existing or hypothetical unit. /// </summary> /// <param name="empire">empire</param> /// <param name="nation">nation of the unit</param> /// <param name="origin">initial unit location</param> /// <param name="domain">unit domain</param> /// <param name="unitSpeed">speed of the unit</param> /// <param name="initialMovementLeft">initial movement points left</param> /// <param name="options">options</param> public TravelSprawl(AEmpire empire, Nation nation, Location origin, ModelDomain domain, int unitSpeed, int initialMovementLeft, Options options) : base(empire, origin, unitSpeed - initialMovementLeft) { this.domain = domain; this.speed = unitSpeed; this.options = options; if (nation != empire.Us) { options |= Options.EmptyPlanet; // default location info relates to own nation, so it can't be considered then } if (nation.HasWonder(Building.ShinkansenExpress)) { options |= Options.ZeroCostRailroad; } if (nation.HasWonder(Building.HangingGardens)) { options |= Options.TerrainResistant; } baseDifficultMoveCost = 100 + (unitSpeed - 150) / 5; if ((options & Options.ZeroCostRailroad) != 0) { baseRailroadMoveCost = 0; } else { baseRailroadMoveCost = (unitSpeed / 50) * 4; } }
public Sprawl(AEmpire empire, Location origin, int startValue) { this.theEmpire = empire; this.originID = origin.ID; this.startValue = startValue; Q = new AddressPriorityQueue(empire.Map.Size - 1); backtrace = new ushort[empire.Map.Size]; }
public Sprawl(AEmpire empire, Location origin, int startValue) { TheEmpire = empire; OriginId = origin.Id; StartValue = startValue; Q = new AddressPriorityQueue(empire.Map.Size - 1); Backtrace = new IdIndexedArray <LocationId, LocationId>(empire.Map.Size); }
public ForeignUnit(AEmpire empire, Location location, ModelBase model, int data2, int data3) { this.theEmpire = empire; this.location = location; this.model = model; this.data2 = data2; this.data3 = data3; }
/// <summary> /// Special unit movement iterator when the goal is to move an own unit adjacent to a certain location. /// </summary> /// <param name="empire">empire</param> /// <param name="unit">the unit</param> /// <param name="approachLocation">loaction to approach to</param> public TravelSprawl(AEmpire empire, AUnit unit, Location approachLocation) : this(empire, unit) { approachLocationID = approachLocation.ID; if (unit.Location != approachLocation) { Q.Disallow(approachLocationID); } }
public MovingUnit(AEmpire empire, int *data) { this.theEmpire = empire; showMoveData = new int[13]; for (int i = 0; i < 13; i++) { showMoveData[i] = data[i]; } }
public Map(AEmpire empire, int sizeX, int sizeY, int landMass) { this.theEmpire = empire; Size = sizeX * sizeY; this.SizeX = sizeX; this.SizeY = sizeY >> 1; this.LandMass = landMass; Ground = (int *)empire.address[1]; ObservedLast = (short *)empire.address[2]; Territory = (sbyte *)empire.address[3]; }
public Map(AEmpire empire, int sizeX, int sizeY, int landMass) { TheEmpire = empire; Size = sizeX * sizeY; SizeX = sizeX; SizeY = sizeY >> 1; LandMass = landMass; Ground = empire.Data->MapData; ObservedLast = empire.Data->LocationLastObservedTurns; Territory = empire.Data->Territory; NeighborLocations = new IdIndexedArray <LocationId, Location[]>(Size); NeighborOtherLocations = new IdIndexedArray <LocationId, OtherLocation[]>(Size); Distance5AreaLocations = new IdIndexedArray <LocationId, Location[]>(Size); Distance5AreaOtherLocations = new IdIndexedArray <LocationId, OtherLocation[]>(Size); JobInfo = new IdIndexedArray <LocationId, JobWorkRemaining[]>(Size); }
static ITradeItem TradeItemFromCode(AEmpire empire, Nation source, int code) { switch (code & Protocol.opMask) { case Protocol.opChoose: return(new ItemOfChoice()); case Protocol.opMap: return(new CopyOfMap()); case Protocol.opCivilReport: return(new CopyOfDossier(new Nation(empire, new NationId((code >> 16) & 0xFF)), code & 0xFFFF)); case Protocol.opMilReport: return(new CopyOfMilitaryReport(new Nation(empire, new NationId((code >> 16) & 0xFF)), code & 0xFFFF)); case Protocol.opMoney: return(new Payment(code & 0xFFFF)); case Protocol.opTech: return(new TeachAdvance((Advance)(code & 0xFFFF))); case Protocol.opAllTech: return(new TeachAllAdvances()); case Protocol.opAllModel: return(new TeachAllModels()); case Protocol.opShipParts: return(new ColonyShipPartLot((Building)((int)Building.ColonyShipComponent + ((code >> 16) & 0xFF)), code & 0xFFFF)); case Protocol.opTreaty: return(new ChangeRelation((Relation)(code & 0xFFFF))); case Protocol.opModel: { if (source == empire.Us) { return(new TeachModel(empire.Models[new ModelId((short)(code & 0xFFFF))])); } else { foreach (ForeignModel model in empire.ForeignModels) { if (model.Nation == source && ((IId)model.OwnersModelId).Index == (code & 0xFFFF)) { return(new TeachModel(model)); } } } throw new Exception("Error in StatementFactory: Foreign model not found!"); } default: throw new Exception("Error in StatementFactory: Not a valid trade item code!"); } }
public static unsafe IStatement OpponentStatementFromCommand(AEmpire empire, Nation opponent, int command, int *rawStream) { switch (command) { case Protocol.scDipNotice: return(new Notice()); case Protocol.scDipAccept: return(new AcceptTrade()); case Protocol.scDipCancelTreaty: return(new CancelTreaty()); case Protocol.scDipOffer: { if (rawStream[0] + rawStream[1] == 0) { return(new SuggestEnd()); } else { ITradeItem[] offers = new ITradeItem[rawStream[0]]; if (rawStream[0] > 0) { for (int i = 0; i < rawStream[0]; i++) { offers[i] = TradeItemFromCode(empire, opponent, rawStream[2 + i]); } } ITradeItem[] wants = new ITradeItem[rawStream[1]]; if (rawStream[1] > 0) { for (int i = 0; i < rawStream[1]; i++) { wants[i] = TradeItemFromCode(empire, empire.Us, rawStream[2 + rawStream[0] + i]); } } return(new SuggestTrade(offers, wants)); } } case Protocol.scDipBreak: return(new Break()); default: throw new Exception("Error in StatementFactory: Not a negotiation!"); } }
public Negotiation(AEmpire empire, Phase negotiationSituation, Nation opponent) { this.theEmpire = empire; this.Situation = negotiationSituation; this.Opponent = opponent; }
public Chunkinizer(AEmpire empire) => TheEmpire = empire;
public ModelList(AEmpire theEmpire) { TheEmpire = theEmpire; EmpirePtr = theEmpire.Data; ModelsPtr = EmpirePtr->ModelsData; }
// for internal use, if used check < Map.Size, because not checked internally public Location(AEmpire empire, int ID) { this.theEmpire = empire; this.ID = ID; this.address = theEmpire.Map.Ground + ID; }
public ExploreSprawl(AEmpire empire, Location origin) : base(empire, empire.Us, origin, ModelDomain.Ground, 150, 150, Options.EmptyPlanet) { }
public ForeignUnitList(AEmpire empire) { theEmpire = empire; address = (int *)empire.address[7]; }
public RestrictedSprawl(AEmpire empire, Location origin, TerrainGroup restriction) : base(empire, origin, 0) { this.restriction = restriction; }
public Negotiation(AEmpire empire, Phase negotiationSituation, Nation opponent) { TheEmpire = empire; Situation = negotiationSituation; Opponent = opponent; }
/// <summary> /// Unit movement iterator for a foreign unit. /// </summary> /// <param name="empire">empire</param> /// <param name="unit">the unit</param> public TravelSprawl(AEmpire empire, ForeignUnit unit) : this(empire, unit.Nation, unit.Location, unit.Model.Domain, unit.Speed, unit.Speed, Options.None) { SetOptionsFromUnit(unit); }
public Location(AEmpire empire, LocationId id) { TheEmpire = empire; Id = id; Data = TheEmpire.Map.Ground + id; }