/// <summary> /// /// </summary> /// <param name="_type"></param> /// <param name="wloc"></param> /// <param name="_height"></param> /// <param name="initiallyOwned"></param> public VarHeightBuilding(VarHeightBuildingContribution _type, WorldLocator wloc, int _height, bool initiallyOwned) { this.type = _type; this.height = _height; int Y = type.Size.Height; int X = type.Size.Width; int Z = height; this.baseLocation = wloc.location; voxels = new VoxelImpl[X, Y, Z]; for (int z = 0; z < Z; z++) { for (int y = 0; y < Y; y++) { for (int x = 0; x < X; x++) { WorldLocator wl = new WorldLocator(wloc.world, baseLocation + new Distance(x, y, z)); voxels[x, y, z] = new VoxelImpl(this, (byte)x, (byte)y, (byte)z, wl); } } } if (wloc.world == WorldDefinition.World) { this.subsidiary = new SubsidiaryCompany(this, initiallyOwned); } if (type.Population != null) { stationListener = new StationListenerImpl( new MultiplierPopulation(height, type.Population), baseLocation); } }
public PopulatedStructure(FixedSizeStructureContribution type, WorldLocator wloc) : base(type, wloc) { if (type.population != null && wloc.world == World.world) { stationListener = new StationListenerImpl(type.population, wloc.location); } }
/// <summary> /// Creates a new commercial structurewith its left-top corner at /// the specified location. /// </summary> /// <param name="_type"> /// Type of the structure to be built. /// </param> /// <param name="initiallyOwned"></param> /// <param name="wloc"></param> public Commercial(CommercialStructureContribution _type, WorldLocator wloc, bool initiallyOwned) : base(_type, wloc) { this.type = _type; if (wloc.world == WorldDefinition.World) { this.subsidiary = new SubsidiaryCompany(this, initiallyOwned); } }
protected override StructureVoxel CreateVoxel(WorldLocator wloc) { if (type.size.x == 1 && type.size.y == 1) { return(new StationaryVoxel(this, wloc)); } else { return(base.CreateVoxel(wloc)); } }
public void PickupClosest() { var closest = WorldLocator.AtObject <ItemPart>(Physical, 2f); var item = closest.FirstOrDefault(i => !i.InStorage); if (item == null) { return; } Pickup(item); }
public PThreeDimStructure(FixedSizeStructureContribution type, WorldLocator wloc) { this.baseLocation = wloc.location; this.type = type; // build voxels for (int z = 0; z < type.size.z; z++) { for (int y = 0; y < type.size.y; y++) { for (int x = 0; x < type.size.x; x++) { CreateVoxel(new WorldLocator(wloc.world, baseLocation + new Distance(x, y, z))); } } } }
/// <summary> /// Creates a new station object with its left-top corner at /// the specified location. /// </summary> /// <param name="_type"> /// Type of the station to be built. /// </param> public Station(StationContribution _type, WorldLocator wloc) : base(_type, wloc) { this.type = _type; this._name = string.Format("ST{0,2:d}", iota++); if (wloc.world == World.world) { World.world.stations.add(this); World.world.clock.registerRepeated(new ClockHandler(clockHandlerHour), TimeLength.fromHours(1)); World.world.clock.registerRepeated(new ClockHandler(clockHandlerDay), TimeLength.fromHours(24)); } Distance r = new Distance(REACH_RANGE, REACH_RANGE, REACH_RANGE); // advertise listeners in the neighborhood that a new station is available foreach (Entity e in Cube.createInclusive(baseLocation - r, baseLocation + r).getEntities()) { StationListener l = (StationListener)e.queryInterface(typeof(StationListener)); if (l != null) { l.advertiseStation(this); } } }
private void tryPickup() { if (!TW.Graphics.Keyboard.IsKeyPressed(Key.F)) { return; } var trader = WorldLocator.AtObject <TraderVisualizerPart>(robot.Physical, 4).FirstOrDefault(); if (trader != null && trader.TraderPart.CanTradeWith(robot)) { trader.TraderPart.PerformTrade(robot); } var resource = WorldLocator.AtObject <GenerationSourcePart>(robot.Physical, 4).FirstOrDefault(); if (resource != null && resource.GenerationPart.HasResource) { resource.GenerationPart.PlayerPickResource(robot); return; } robot.PickupClosest(); }
/// <summary> /// Creates a new commercial structurewith its left-top corner at /// the specified location. /// </summary> /// <param name="_type"> /// Type of the structure to be built. /// </param> public StadiumStructure(StructureContributionImpl _type, WorldLocator wloc) : base(_type, wloc) { // this.type = _type; // register once a month timer for the strength/popularity decay World.world.clock.registerRepeated(new ClockHandler(onClock), TimeLength.fromDays(30)); // schedule initial games // minutes to the next day midnight TimeLength b = TimeLength.fromMinutes( TimeLength.ONEDAY.totalMinutes - (World.world.clock.totalMinutes % TimeLength.ONEDAY.totalMinutes)); // the first game is set to 14:00 that day. b += TimeLength.fromHours(14); for (int i = 0; i < Const.SCHEDULE_DAYS; i += 7) { scheduleNewGame(b); scheduleNewGame(b + TimeLength.fromHours(24 * 3 + 5)); // schdule a nighter b += TimeLength.fromDays(7); } }
/// <summary> /// /// </summary> /// <param name="wLoc"></param> /// <param name="initiallyOwned"></param> /// <returns></returns> public override Structure Create(WorldLocator wLoc, bool initiallyOwned) { return(new Station(this, wLoc)); }
/// <summary> /// /// </summary> /// <param name="wLoc"></param> /// <param name="initiallyOwned"></param> /// <returns></returns> public override Structure Create(WorldLocator wLoc, bool initiallyOwned) { return(new Commercial(this, wLoc, initiallyOwned)); }
internal protected DummyVoxel(WorldLocator wloc) : base(wloc) { }
/// <summary> /// /// </summary> /// <param name="owner"></param> /// <param name="wloc"></param> internal protected HalfDividedVoxel(HVStructure owner, WorldLocator wloc) : base(wloc) { this.owner = owner; }
internal StationaryVoxel(PThreeDimStructure _owner, WorldLocator wloc) : base(_owner, wloc) { }
/// <summary> /// /// </summary> /// <param name="wloc"></param> /// <param name="initiallyOwned"></param> /// <returns></returns> public abstract Structure Create(WorldLocator wloc, bool initiallyOwned);
/// <summary> /// Creates a new instance of this structure type to the specified location. /// </summary> public Structure create(WorldLocator wLoc, int height, bool initiallyOwned) { return(new VarHeightBuilding(this, wLoc, height, initiallyOwned)); }
protected virtual StructureVoxel CreateVoxel(WorldLocator loc) { return(new VoxelImpl(this, loc)); }
/// <summary> /// /// </summary> /// <param name="_owner"></param> /// <param name="wloc"></param> protected StructureVoxel(Structure _owner, WorldLocator wloc) : base(wloc) { this.owner = _owner; }
/// <summary> /// /// </summary> /// <param name="_owner"></param> /// <param name="_x"></param> /// <param name="_y"></param> /// <param name="_z"></param> /// <param name="wloc"></param> protected internal VoxelImpl(VarHeightBuilding _owner, byte _x, byte _y, byte _z, WorldLocator wloc) : base(_owner, wloc) { this.x = _x; this.y = _y; this.z = _z; }
public override Structure create(WorldLocator wLoc, bool initiallyOwned) { return(new RailStationaryStructure(this, wLoc)); }
public RailStationaryStructure(RailStationaryContribution type, WorldLocator wloc) : base(type, wloc) { }
internal VoxelImpl(PThreeDimStructure _owner, WorldLocator wloc) : base(_owner, wloc) { setSprite(); }
/// <summary> /// Gets the island the robot is standing on, null if none /// </summary> /// <returns></returns> public IslandPart GetPositionIsland() { return(WorldLocator.AtObject <IslandPart>(Physical, 3).FirstOrDefault()); }