public static UnityInstance requestInstance(String instanceName, UnityInstanceData data) { if (instances.containsKey(instanceName)) { return null; } UnityInstanceStatus instanceStatus = new UnityInstanceStatus(); UnityInstance instance = new UnityInstance(instanceStatus); instance.assigned = false; instance.running = false; instanceStatus.name = instanceName; instanceStatus.data = data; instances.put(instanceName, instance); return instance; }
private boolean assignInstance(UnityInstance instance) { Player player = PlayerService.getInstance().assignUnityAgent(); if (player == null) { logger.debug("Unable to assign player for unity instance " + instance.status.name); return false; } UnityInstanceStatus status = instance.status; status.playerId = player.id; status.requestedState = UnityInstanceStatus.State.Running; status.state = UnityInstanceStatus.State.None; status.zone = ZoneService.getZone(status.name); PlayerService.getInstance().setZone(status.playerId, status.zone); GridService.getInstance().createForZone(status.zone.number); zoneToName.put(status.zone.number, status.name); instance.assigned = true; return true; }