protected override void ServerOnDropEventStarted(ILogicObject activeEvent) { var publicState = GetPublicState(activeEvent); ServerEventLocationManager.AddUsedLocation( publicState.AreaCirclePosition, publicState.AreaCircleRadius + 20, duration: TimeSpan.FromHours(12)); }
protected override Vector2Ushort ServerPickEventPosition(ILogicObject activeEvent) { for (var globalAttempt = 0; globalAttempt < 5; globalAttempt++) { // pick up a zone which doesn't contain an active event of the same type var attempts = 50; IServerZone zoneInstance; do { zoneInstance = this.ServerSelectRandomZoneWithEvenDistribution(serverSpawnZones.Value); if (this.ServerCheckNoSameEventsInZone(zoneInstance)) { break; } zoneInstance = null; }while (--attempts > 0); if (zoneInstance is null) { throw new Exception("Unable to pick an event position"); } // pick up a valid position inside the zone attempts = 250; do { var result = zoneInstance.GetRandomPosition(RandomHelper.Instance); if (this.ServerIsValidEventPosition(result) && !ServerEventLocationManager.IsLocationUsedRecently(result, this.AreaRadius) && this.ServerCheckNoEventsNearby(result, this.AreaRadius * 4)) { return(result); } }while (--attempts > 0); } throw new Exception("Unable to pick an event position"); }