public NetworkRunner(CvarcClient client) { this.client = client; factory = new SoloNetworkControllerFactory(client); var configProposal = client.Read<ConfigurationProposal>(); var loadingData = configProposal.LoadingData; var competitions = Dispatcher.Loader.GetCompetitions(loadingData); var settings = competitions.Logic.CreateDefaultSettings(); if (configProposal.SettingsProposal != null) configProposal.SettingsProposal.Push(settings, true); configuration = new Configuration { LoadingData = loadingData, Settings = settings }; //configuration.Settings.EnableLog = true; //configuration.Settings.LogFile = UnityConstants.LogFolderRoot + "cvarclog1"; var worldSettingsType = competitions.Logic.WorldStateType; worldState = (IWorldState)client.Read(worldSettingsType); Name = loadingData.AssemblyName + loadingData.Level; CanInterrupt = true; CanStart = true; }
public override List <Action> GenerateSatisfyingActions(IWorldState worldState, int maxActions) { List <Action> actions = new List <Action>(); IEntity entity = worldState.GetEntity(entityId); float powerDiff = minPower - entity.GetPower(); if (powerDiff <= 0) { return(actions); } ItemFilter filter = new ItemFilter(); filter.requireEquippable = true; for (int i = 0; i < Item.numItemSlots; i++) { if (entity.TryGetEquippedItem((ItemSlot)i, out Item item)) { filter.minPower[i] = powerDiff + item.power; } else { filter.minPower[i] = powerDiff; } } EquipAction equipAction = new EquipAction(worldState, entityId, filter); actions.Add(equipAction); return(actions); }
protected override void GenerateConditions(IWorldState worldState) { conditions = new List <Condition>(); PossessCondition possessCond = new PossessCondition(entityId, itemFilter); conditions.Add(possessCond); }
private IEnumerator RefreshProfilingData() { while (true) { var currentPos = Utils.WorldToGridPosition(DCLCharacterController.i.characterPosition.worldPosition); IWorldState worldState = Environment.i.world.state; ParcelScene activeScene = worldState.loadedScenes.Values.FirstOrDefault( x => x.sceneData.parcels != null && x.sceneData.parcels.Any(y => y == currentPos)) as ParcelScene; if (activeScene != null && activeScene.metricsController != null) { var metrics = activeScene.metricsController.GetModel(); var limits = activeScene.metricsController.GetLimits(); statsPanel.SetCellText((int)Columns.VALUE, (int)Rows.CURRENT_SCENE, $"{activeScene.sceneData.id}"); statsPanel.SetCellText((int)Columns.VALUE, (int)Rows.POLYGONS_VS_LIMIT, $"{metrics.triangles} of {limits.triangles}"); statsPanel.SetCellText((int)Columns.VALUE, (int)Rows.TEXTURES_VS_LIMIT, $"{metrics.textures} of {limits.textures}"); statsPanel.SetCellText((int)Columns.VALUE, (int)Rows.MATERIALS_VS_LIMIT, $"{metrics.materials} of {limits.materials}"); statsPanel.SetCellText((int)Columns.VALUE, (int)Rows.ENTITIES_VS_LIMIT, $"{metrics.entities} of {limits.entities}"); statsPanel.SetCellText((int)Columns.VALUE, (int)Rows.MESHES_VS_LIMIT, $"{metrics.meshes} of {limits.meshes}"); statsPanel.SetCellText((int)Columns.VALUE, (int)Rows.BODIES_VS_LIMIT, $"{metrics.bodies} of {limits.bodies}"); statsPanel.SetCellText((int)Columns.VALUE, (int)Rows.COMPONENT_OBJECTS_COUNT, activeScene.disposableComponents.Count + activeScene.entities.Select(x => x.Value.components.Count).Sum().ToString()); } yield return(WaitForSecondsCache.Get(0.2f)); } }
public void LoadParcelScenesExecute(string scenePayload) { LoadParcelScenesMessage.UnityParcelScene scene; ProfilingEvents.OnMessageDecodeStart?.Invoke(MessagingTypes.SCENE_LOAD); scene = Utils.SafeFromJson <LoadParcelScenesMessage.UnityParcelScene>(scenePayload); ProfilingEvents.OnMessageDecodeEnds?.Invoke(MessagingTypes.SCENE_LOAD); if (scene == null || scene.id == null) { return; } var sceneToLoad = scene; DebugConfig debugConfig = DataStore.i.debugConfig; #if UNITY_EDITOR if (debugConfig.soloScene && sceneToLoad.basePosition.ToString() != debugConfig.soloSceneCoords.ToString()) { SendSceneReady(sceneToLoad.id); return; } #endif ProfilingEvents.OnMessageProcessStart?.Invoke(MessagingTypes.SCENE_LOAD); IWorldState worldState = Environment.i.world.state; if (!worldState.loadedScenes.ContainsKey(sceneToLoad.id)) { var newGameObject = new GameObject("New Scene"); var newScene = newGameObject.AddComponent <ParcelScene>(); newScene.SetData(sceneToLoad); if (debugConfig.isDebugMode) { newScene.InitializeDebugPlane(); } newScene.ownerController = this; worldState.loadedScenes.Add(sceneToLoad.id, newScene); worldState.scenesSortedByDistance.Add(newScene); sceneSortDirty = true; OnNewSceneAdded?.Invoke(newScene); Environment.i.messaging.manager.AddControllerIfNotExists(this, newScene.sceneData.id); if (VERBOSE) { Debug.Log($"{Time.frameCount} : Load parcel scene {newScene.sceneData.basePosition}"); } } ProfilingEvents.OnMessageProcessEnds?.Invoke(MessagingTypes.SCENE_LOAD); }
public void UnloadParcelSceneExecute(string sceneId) { ProfilingEvents.OnMessageProcessStart?.Invoke(MessagingTypes.SCENE_DESTROY); IWorldState worldState = Environment.i.world.state; if (!worldState.loadedScenes.ContainsKey(sceneId) || worldState.loadedScenes[sceneId].isPersistent) { return; } var scene = worldState.loadedScenes[sceneId]; worldState.loadedScenes.Remove(sceneId); // Remove the scene id from the msg. priorities list worldState.scenesSortedByDistance.Remove(scene); // Remove messaging controller for unloaded scene Environment.i.messaging.manager.RemoveController(scene.sceneData.id); if (scene) { scene.Cleanup(!CommonScriptableObjects.rendererState.Get()); if (VERBOSE) { Debug.Log($"{Time.frameCount} : Destroying scene {scene.sceneData.basePosition}"); } } ProfilingEvents.OnMessageProcessEnds?.Invoke(MessagingTypes.SCENE_DESTROY); }
public override float EstimateCost(IWorldState worldState) { Merchant merchant = worldState.GetMerchant(merchantId); float salePrice = merchant.saleEntries[saleEntryIndex].price; return(salePrice); }
public void UnloadScene(string sceneKey) { var queuedMessage = new QueuedSceneMessage() { type = QueuedSceneMessage.Type.UNLOAD_PARCEL, message = sceneKey }; ProfilingEvents.OnMessageWillQueue?.Invoke(MessagingTypes.SCENE_DESTROY); Environment.i.messaging.manager.ForceEnqueueToGlobal(MessagingBusType.INIT, queuedMessage); Environment.i.messaging.manager.RemoveController(sceneKey); IWorldState worldState = Environment.i.world.state; if (worldState.loadedScenes.ContainsKey(sceneKey)) { ParcelScene sceneToUnload = worldState.GetScene(sceneKey) as ParcelScene; sceneToUnload.isPersistent = false; if (sceneToUnload is GlobalScene globalScene && globalScene.isPortableExperience) { OnNewPortableExperienceSceneRemoved?.Invoke(sceneKey); } } }
public override float EstimateCost(IWorldState worldState) { IEntity entity = worldState.GetEntity(entityID); float dist = PathFinder.EstimateDistance(entity.Position, targetPos); return(dist); }
public BuyAction(IWorldState worldState, int buyerId, int saleEntryIndex, int merchantId) { this.buyerId = buyerId; this.saleEntryIndex = saleEntryIndex; this.merchantId = merchantId; GenerateConditions(worldState); }
public TournamentPlayer(IMessagingClient client, ConfigurationProposal configProposal, IWorldState preferredWorldState) { this.client = client; this.configProposal = configProposal; this.preferredWorldState = preferredWorldState; }
public PlannerState(IWorldState workingWS, List <TaskBase> finalPlanList, List <TaskBase> taskListToProcess, int nextMethodNumber) { this.WorkingWS = workingWS; this.FinalPlanList = finalPlanList; this.TaskListToProcess = taskListToProcess; this.NextMethodNumber = nextMethodNumber; }
public TournamentRunner(IWorldState worldState, Configuration configuration) { this.worldState = worldState; this.configuration = configuration; players = new List<TournamentPlayer>(); //log section logFileName = Guid.NewGuid() + ".log"; configuration.Settings.EnableLog = true; configuration.Settings.LogFile = UnityConstants.LogFolderRoot + logFileName; //log section end var competitions = Dispatcher.Loader.GetCompetitions(configuration.LoadingData); controllerIds = competitions.Logic.Actors.Keys.ToArray(); foreach (var controller in controllerIds .Select(x => new ControllerSettings { ControllerId = x, Type = ControllerType.Client, Name = configuration.Settings.Name })) configuration.Settings.Controllers.Add(controller); requiredCountOfPlayers = controllerIds.Length; Debugger.Log(DebuggerMessageType.Unity, "t.runner created. count: " + requiredCountOfPlayers); if (requiredCountOfPlayers == 0) throw new Exception("requiered count of players cant be 0"); Name = configuration.LoadingData.AssemblyName + configuration.LoadingData.Level;//"Tournament"; CanInterrupt = false; CanStart = false; }
public override List <Action> GenerateSatisfyingActions(IWorldState worldState, int maxActions) { List <Action> actions = new List <Action>(); MoveAction moveAction = new MoveAction(worldState, entityID, position); actions.Add(moveAction); return(actions); }
public PlayerEntityManagerFactory(IWorldState worldState, IStateManager stateManager, BattleManagerFactory battleManagerFactory) { _worldState = worldState; _stateManager = stateManager; _battleManagerFactory = battleManagerFactory; }
/// <summary> /// Creates a world. /// </summary> /// <param name="configuration">Contains the cometition/level name and the settings</param> /// <param name="controllerFactory">Is used to create controllers, i.e. entities that control the robots</param> /// <param name="state">The initial state of the world</param> /// <returns></returns> public IWorld CreateWorld(Configuration configuration, ControllerFactory controllerFactory, IWorldState state) { var competitions = GetCompetitions(configuration.LoadingData); var world = competitions.Logic.CreateWorld(); world.Initialize(competitions, configuration, controllerFactory, state); world.Exit += ()=> controllerFactory.Exit(); return world; }
public static ConditionNode GeneratePlan(Condition condition, IWorldState worldState, int depth, int width) { LinkedList <Condition> stack = new LinkedList <Condition>(); stack.AddFirst(condition); ConditionNode topNode = FillTree(stack, worldState, depth, width); return(topNode); }
public static void AddForceGame(IWorldState worldState, Configuration config) { if (forceRunner != null) while (!forceRunner.Disposed) Thread.Sleep(100); haveForceGame = true; lock (pool) pool.Clear(); forceRunner = new TournamentRunner(worldState, config); Dispatcher.AddRunner(forceRunner); }
void Awake() { worldStates = new Dictionary <StateName, IWorldState>(); // fill dictionary worldStates.Add(StateName.Idle, new Idle(this)); worldStates.Add(StateName.RollCall, new RollCall(this)); worldStates.Add(StateName.Selection, new Selection(this)); worldStates.Add(StateName.Temp, new Temp(this)); worldStates.Add(StateName.Final, new Final(this)); current = worldStates[StateName.Idle]; }
public PlayerEntityManager(IWorldState worldState, IStateManager stateManager, IPlayerEntityManagerStore playerEntityManagerStore) { _worldState = worldState; _stateManager = stateManager; _playerEntityManagerStore = playerEntityManagerStore; LastAccessed = DateTime.Now; _movementQueue = new Queue <Coordinate>(); AlliedEntities = new List <WorldEntity>(); }
public WorldEntityManager(IWorldEntityFactory worldEntityFactory, PlayerEntityManagerFactory playerEntityManagerFactory, IWorldState worldState) { _worldEntityFactory = worldEntityFactory; _playerEntityManagerFactory = playerEntityManagerFactory; _worldState = worldState; _worldEntities = new ConcurrentDictionary <Guid, WorldEntity>(); _playerEntityManagers = new ConcurrentDictionary <Guid, PlayerEntityManager>(); _combatEntities = new List <CombatEntity>(); }
public bool CheckPreCondition(IWorldState state) { foreach (var preCondition in PreConditions) { if (!preCondition.CheckPreCondition(state)) { return(false); } } return(true); }
protected override void GenerateConditions(IWorldState worldState) { Merchant merchant = worldState.GetMerchant(merchantId); conditions = new List <Condition>(); MoneyCondition moneyCond = new MoneyCondition(buyerId, merchant.saleEntries[saleEntryIndex].price); conditions.Add(moneyCond); LocationCondition locationCond = new LocationCondition(buyerId, merchant.position); conditions.Add(locationCond); }
/// <summary> /// 登録されているOperatorの実行、監視を行う /// </summary> private CurrentOperatorStatus UpdateCurrentOperator(IWorldState worldState) { if (operatorList.Count == 0) { return(CurrentOperatorStatus.Success); } // Operatorの実行処理(まだ作れてない) // return CurrentOperatorStatus.Continue; operatorList[0].Execute(worldState); return(CurrentOperatorStatus.Success); }
private MevBlockProductionTransactionsExecutor( ITransactionProcessor transactionProcessor, IStateProvider stateProvider, IStorageProvider storageProvider, ISpecProvider specProvider, ILogManager logManager) : base(transactionProcessor, stateProvider, storageProvider, specProvider, logManager) { _stateProvider = stateProvider; _storageProvider = storageProvider; _worldState = new WorldState(stateProvider, storageProvider); }
public void SortScenesByDistance() { if (DCLCharacterController.i == null) { return; } IWorldState worldState = Environment.i.world.state; worldState.currentSceneId = null; worldState.scenesSortedByDistance.Sort(SortScenesByDistanceMethod); using (var iterator = Environment.i.world.state.scenesSortedByDistance.GetEnumerator()) { IParcelScene scene; bool characterIsInsideScene; while (iterator.MoveNext()) { scene = iterator.Current; if (scene == null) { continue; } characterIsInsideScene = WorldStateUtils.IsCharacterInsideScene(scene); if (!worldState.globalSceneIds.Contains(scene.sceneData.id) && characterIsInsideScene) { worldState.currentSceneId = scene.sceneData.id; break; } } } if (!DataStore.i.debugConfig.isDebugMode && string.IsNullOrEmpty(worldState.currentSceneId)) { // When we don't know the current scene yet, we must lock the rendering from enabling until it is set CommonScriptableObjects.rendererState.AddLock(this); } else { // 1. Set current scene id CommonScriptableObjects.sceneID.Set(worldState.currentSceneId); // 2. Attempt to remove SceneController's lock on rendering CommonScriptableObjects.rendererState.RemoveLock(this); } OnSortScenes?.Invoke(); }
public LogRunner(string fileName) { var log = Log.Load(UnityConstants.LogFolderRoot + fileName); factory = new LogPlayerControllerFactory(log); configuration = log.Configuration; configuration.Settings.EnableLog = false; // чтоб файл логов не переписывать worldState = log.WorldState; Name = "log run: " + fileName; CanInterrupt = true; CanStart = true; }
public override void ExecuteImmediate(IWorldState worldState) { IEntity entity = worldState.GetEntity(entityId); foreach (Item item in entity.GetInventory()) { if (itemFilter.Satisfied(item) && item.equippable) { entity.EquipItem(item, item.slot); return; } } }
public BattleListenerContainer(IHubContext <BattleHub> battleHubContext, IWorldState worldState) { _battleHubContext = battleHubContext; _worldState = worldState; //foreach (var manager in _worldState.MapBattleManagers.Values) //{ // manager.OnCreatedBattle += (sender, args) => // { // CreateListener(args.BattleManager); // }; //} }
public override void ExecuteImmediate(IWorldState worldState) { IEntity buyer = worldState.GetEntity(buyerId); Merchant merchant = worldState.GetMerchant(merchantId); float salePrice = merchant.saleEntries[saleEntryIndex].price; if (buyer.Money > salePrice) { Item item = merchant.saleEntries[saleEntryIndex].itemTemplate.Generate(); buyer.AddInventoryItem(item); buyer.Money -= salePrice; } }
override public bool Satisfied(IWorldState worldState) { IEntity owner = worldState.GetEntity(ownerId); foreach (Item i in owner.GetInventory()) { if (itemFilter.Satisfied(i)) { return(true); } } return(false); }
public WorldRuntimeContext(IWorldState state, ISceneController sceneController, IPointerEventsController pointerEventsController, ISceneBoundsChecker sceneBoundsChecker, IWorldBlockersController blockersController, IRuntimeComponentFactory componentFactory) { this.state = state; this.sceneController = sceneController; this.pointerEventsController = pointerEventsController; this.sceneBoundsChecker = sceneBoundsChecker; this.blockersController = blockersController; this.componentFactory = componentFactory; }
public bool ProcessMessage(QueuedSceneMessage_Scene msgObject, out CustomYieldInstruction yieldInstruction) { string sceneId = msgObject.sceneId; string method = msgObject.method; yieldInstruction = null; IParcelScene scene; bool res = false; IWorldState worldState = Environment.i.world.state; DebugConfig debugConfig = DataStore.i.debugConfig; if (worldState.loadedScenes.TryGetValue(sceneId, out scene)) { #if UNITY_EDITOR if (debugConfig.soloScene && scene is GlobalScene && debugConfig.ignoreGlobalScenes) { return(false); } #endif if (!scene.GetSceneTransform().gameObject.activeInHierarchy) { return(true); } #if UNITY_EDITOR OnMessageProcessInfoStart?.Invoke(sceneId, method); #endif ProfilingEvents.OnMessageProcessStart?.Invoke(method); ProcessMessage(scene as ParcelScene, method, msgObject.payload, out yieldInstruction); ProfilingEvents.OnMessageProcessEnds?.Invoke(method); #if UNITY_EDITOR OnMessageProcessInfoEnds?.Invoke(sceneId, method); #endif res = true; } else { res = false; } sceneMessagesPool.Enqueue(msgObject); return(res); }
public TransactionProcessor( ISpecProvider?specProvider, IWorldState?worldState, IVirtualMachine?virtualMachine, ILogManager?logManager) { _logger = logManager?.GetClassLogger() ?? throw new ArgumentNullException(nameof(logManager)); _specProvider = specProvider ?? throw new ArgumentNullException(nameof(specProvider)); _worldState = worldState ?? throw new ArgumentNullException(nameof(worldState)); _stateProvider = worldState.StateProvider; _storageProvider = worldState.StorageProvider; _virtualMachine = virtualMachine ?? throw new ArgumentNullException(nameof(virtualMachine)); _ecdsa = new EthereumEcdsa(specProvider.ChainId, logManager); }
public void CreateUIScene(string json) { #if UNITY_EDITOR DebugConfig debugConfig = DataStore.i.debugConfig; if (debugConfig.soloScene && debugConfig.ignoreGlobalScenes) { return; } #endif CreateUISceneMessage uiScene = Utils.SafeFromJson <CreateUISceneMessage>(json); string uiSceneId = uiScene.id; IWorldState worldState = Environment.i.world.state; if (worldState.loadedScenes.ContainsKey(uiSceneId)) { return; } var newGameObject = new GameObject("UI Scene - " + uiSceneId); var newScene = newGameObject.AddComponent <GlobalScene>(); newScene.ownerController = this; newScene.unloadWithDistance = false; newScene.isPersistent = true; LoadParcelScenesMessage.UnityParcelScene data = new LoadParcelScenesMessage.UnityParcelScene { id = uiSceneId, basePosition = new Vector2Int(0, 0), baseUrl = uiScene.baseUrl }; newScene.SetData(data); worldState.loadedScenes.Add(uiSceneId, newScene); OnNewSceneAdded?.Invoke(newScene); worldState.globalSceneId = uiSceneId; Environment.i.messaging.manager.AddControllerIfNotExists(this, worldState.globalSceneId, isGlobal: true); if (VERBOSE) { Debug.Log($"Creating UI scene {uiSceneId}"); } }
private static ParcelScene GetLoadedScene() { ParcelScene loadedScene = null; IWorldState worldState = Environment.i.world.state; if (worldState != null && worldState.loadedScenes.Count > 0) { using (var iterator = worldState.loadedScenes.GetEnumerator()) { iterator.MoveNext(); loadedScene = iterator.Current.Value; } } return(loadedScene); }
public static void AddPlayerToPool(CvarcClient client, Configuration configuration, IWorldState worldState, ConfigurationProposal configProposal) { if (haveForceGame) { if (UnityConstants.OnlyGamesThroughServicePort) HttpWorker.SendInfoToLocal(configProposal.SettingsProposal.CvarcTag); if (forceRunner.AddPlayerAndCheck(new TournamentPlayer(client, configProposal, worldState))) haveForceGame = false; return; } lock (pool) { if (!pool.ContainsKey(configuration.LoadingData)) { pool.Add(configuration.LoadingData, new TournamentRunner(worldState, configuration)); Dispatcher.AddRunner(pool[configuration.LoadingData]); } if (pool[configuration.LoadingData].AddPlayerAndCheck(new TournamentPlayer(client, configProposal, worldState))) pool.Remove(configuration.LoadingData); } }
readonly IWorldState worldState; // откуда? #endregion Fields #region Constructors public TutorialRunner(LoadingData loadingData, Configuration configuration = null, IWorldState worldState = null) { factory = new TutorialControllerFactory(); var competitions = Dispatcher.Loader.GetCompetitions(loadingData); if (configuration == null) { this.configuration = new Configuration { LoadingData = loadingData, Settings = competitions.Logic.CreateDefaultSettings() }; } else this.configuration = configuration; this.worldState = worldState ?? competitions.Logic.CreateWorldState(competitions.Logic.PredefinedWorldStates[0]); //this.worldState = worldState ?? competitions.Logic.CreateWorldState("0"); // lol Name = "Tutorial"; CanStart = true; CanInterrupt = true; }
public TournamentRunner(LoadingData loadingData, IWorldState worldState) { this.worldState = worldState; players = new List<TournamentPlayer>(); var competitions = Dispatcher.Loader.GetCompetitions(loadingData); var settings = competitions.Logic.CreateDefaultSettings(); configuration = new Configuration { LoadingData = loadingData, Settings = settings }; //я игнорирую конфиги. надо хотя бы имя сохранять в метод "add player" controllerIds = competitions.Logic.Actors.Keys.ToArray(); foreach (var controller in controllerIds .Select(x => new ControllerSettings { ControllerId = x, Type = ControllerType.Client, Name = settings.Name })) settings.Controllers.Add(controller); requiredCountOfPlayers = controllerIds.Length; Debugger.Log(DebuggerMessageType.Unity, "t.runner created. count: " + requiredCountOfPlayers); if (requiredCountOfPlayers == 0) throw new Exception("requiered count of players cant be 0"); Name = loadingData.AssemblyName + loadingData.Level;//"Tournament"; CanInterrupt = false; CanStart = false; }
void Start() { //Screen.SetResolution(640, 480, true); Screen.SetResolution(320, 200, true); mainMenuState = new MenuWorldState(); mainMenuState.Create(); mainMenuState.Run(); toLoad = ""; }
public WorldState(IWorldState state) { State = state; }
public void RequestState(string stateIn) { //return; if(stateIn == "Menu") { if(gameState != null) { gameState.Pause(); gameState.Hide(); gameState.Teardown(); gameState = null; } mainMenuState.Show(false); mainMenuState.Run(); } if(stateIn == "GameMenu") { if(gameState != null) { gameState.Pause(); } mainMenuState.Show(true); mainMenuState.Run(); } if(stateIn == "Continue") { if(gameState != null) { gameState.Run(); gameState.Show(false); mainMenuState.Hide(); mainMenuState.Pause(); } } if(stateIn == "NewGame") { if(gameState != null) { gameState.Hide(); gameState.Teardown(); gameState = null; } toLoad = "load_Game"; } if(stateIn == "SaveQuit") { if(gameState != null) { gameState.Hide(); gameState.Teardown(); gameState = null; } mainMenuState.Teardown(); mainMenuState.Hide(); // mainMenuState = null; Application.Quit(); } //TOLOAD if(stateIn == "load_Game") { toLoad = ""; mainMenuState.Hide(); gameState = new GameWorldState(WorldCreate.WorldType.debug_game); gameState.Create(); gameState.Run(); } }