private static void ServerGatherValuableStructures( RectangleInt areaBounds, HashSet <IStaticWorldObject> result) { for (var x = areaBounds.X; x < areaBounds.X + areaBounds.Width; x++) { for (var y = areaBounds.Y; y < areaBounds.Y + areaBounds.Height; y++) { if (x < 0 || y < 0 || x >= ushort.MaxValue || y >= ushort.MaxValue) { continue; } var staticObjects = ServerWorld.GetStaticObjects(new Vector2Ushort((ushort)x, (ushort)y)); foreach (var worldObject in staticObjects) { var prototype = worldObject.ProtoStaticWorldObject; if (prototype is IProtoObjectStructure protoObjectStructure && protoObjectStructure.FactionWealthScorePoints > 0) { result.Add(worldObject); } } } } }
/// <summary> /// This method is usually used when a land claim building is destroyed /// - to force all the buildings to start decay almost immediately. /// </summary> public static void ServerBeginDecayForStructuresInArea(RectangleInt areaBounds) { var decayStartTime = ServerGame.FrameTime + (5 * 60); for (var x = areaBounds.X; x < areaBounds.X + areaBounds.Width; x++) { for (var y = areaBounds.Y; y < areaBounds.Y + areaBounds.Height; y++) { if (x < 0 || y < 0 || x >= ushort.MaxValue || y >= ushort.MaxValue) { continue; } var staticObjects = ServerWorld.GetStaticObjects(new Vector2Ushort((ushort)x, (ushort)y)); foreach (var worldObject in staticObjects) { var prototype = worldObject.ProtoStaticWorldObject; if (prototype is IProtoObjectStructure && !(prototype is IProtoObjectLandClaim)) { var privateState = worldObject.GetPrivateState <StructurePrivateState>(); privateState.ServerDecayStartTime = decayStartTime; } } } } }