static void OnProjectWindowItemOnGUI(string guid, Rect selectionRect) { string noteId = guid; bool isHoldingRequiredKeys = (Event.current.modifiers & EditorNotesSettings.MODIFIER_KEY) != EventModifiers.None; if (isHoldingRequiredKeys) // user pressed the correct key { if (selectionRect.Contains(Event.current.mousePosition)) // we're drawing the item that the user is pointing on { // _________________________________________ Begin / End note _________________________________________ // if (!EditorNotesViewData.IsEditingNote) { s_noteId.Set(noteId); if (s_noteId.ClearDirty()) { if (!string.IsNullOrEmpty(s_noteId.GetPrevious())) { OnEndNote(s_noteId.GetPrevious()); } OnBeginNote(s_noteId.Get()); } } s_lastDrawTime = EditorApplication.timeSinceStartup; } } else if (CanEndNoteAndClose()) { EndNoteAndClose(); } // _________________________________________ Draw _________________________________________ // if (s_noteId.Get() == noteId) { EditorNotesDrawer.DrawNote(selectionRect); EditorNotesDrawer.DrawSelectionBorder(selectionRect); if (!EditorNotesViewData.IsEditingNote) { EditorNotesDrawer.DrawEditNoteButton(selectionRect); } } if (EditorNotesDatabase.Instance.ContainsNote(noteId)) { EditorNotesDrawer.DrawNoteIcon(selectionRect); } s_requestRepaint = isHoldingRequiredKeys || EditorNotesViewData.IsEditingNote; // needed for responsive UI }
public static void Update() { if (Input.GetKey(KeyCode.C) && !GameConsole.IsOpen()) { if (Input.GetKeyDown(KeyCode.T)) { CheatTeleportAtMouse(); } } var cache = GamePresentationCache.Instance; s_globalGroupEnabled.Set(cache?.SimWorld != null && cache.SimWorld.HasSingleton <GridInfo>()); s_localPawnGroupEnabled.Set(s_globalGroupEnabled && cache.SimWorld.Exists(GamePresentationCache.Instance.LocalPawn)); s_localPlayerGroupEnabled.Set(s_globalGroupEnabled && GamePresentationCache.Instance.LocalControllerExists); if (s_globalGroupEnabled.ClearDirty()) { GameConsole.SetGroupEnabled(GLOBAL_GROUP, s_globalGroupEnabled); } if (s_localPawnGroupEnabled.ClearDirty()) { GameConsole.SetGroupEnabled(LOCAL_PAWN_GROUP, s_localPawnGroupEnabled); } if (s_localPlayerGroupEnabled.ClearDirty()) { GameConsole.SetGroupEnabled(LOCAL_PLAYER_GROUP, s_localPlayerGroupEnabled); } }
protected override void OnGamePresentationUpdate() { _visuallyOn.Set(_isOn || (_wasOn && _onTimer < MinOnDuration) || (_visuallyOn && _onTimer < MinOnDuration)); _wasOn = false; if (_visuallyOn) { _onTimer += Time.deltaTime; } else { _onTimer = 0; } if (_visuallyOn.ClearDirty()) { VisualsOn.SetActive(_visuallyOn); VisualsOff.SetActive(!_visuallyOn); // update emitter click sprite if needed if (_emitterClicker != null) { _emitterClicker.SetSprite(_visuallyOn ? VisualsOn.GetComponentInChildren <SpriteRenderer>() : VisualsOff.GetComponentInChildren <SpriteRenderer>()); } } }
void OnFixedUpdate() { if (!GamePresentationCache.Instance.Ready) { return; } SimulationWorld simWorld = (SimulationWorld)GamePresentationCache.Instance.SimWorld.EntityManager.World; _currentSimTick.Set(simWorld.LatestTickId); // 'not dirty' means no change. That means the simulation has NOT played a sim tick this past fixed update _offsettedSimTicks[_offsettedSimTicksIterator] = !_currentSimTick.IsDirty; _offsettedSimTicksIterator++; _offsettedSimTicksIterator %= _offsettedSimTicks.Length; if (_offsettedSimTicksIterator == 0) { _totalOffsettedSimTicks = 0; for (int i = 0; i < _offsettedSimTicks.Length; i++) { if (_offsettedSimTicks[i]) { _totalOffsettedSimTicks++; } } } _currentSimTick.ClearDirty(); }
protected override void OnGamePresentationUpdate() { if (SimEntity != Entity.Null && SimWorld.TryGetComponent(SimEntity, out Name name)) { _displayName.Set(name); } else { _displayName.Set(default);
protected override void OnGamePresentationUpdate() { _lifePoints.Set(Cache.GroupLifePoints); if (_lifePoints.ClearDirty()) { _counterText.text = _lifePoints.Get().ToString(); } }
private void UpdateData() { _displayedMessage.Set(null); if (Cache.PointerInWorld && Cache.LocalPawn != Entity.Null) { if (distance(Cache.DEPRECATED_LocalPawnTile, Cache.PointedTile) <= _readRange) { foreach (var tileActor in Cache.PointedBodies) { if (SimWorld.TryGetComponent(tileActor, out Message message)) { _displayedMessage.Set(message); _messagePosition.Set((Vector2)(fix2)SimWorld.GetComponent <FixTranslation>(tileActor)); break; } } } } }
protected override IEnumerator SurveyRoutine(Context context, List <GameAction.ParameterData> result, System.Action complete, System.Action cancel) { _currentNumber.Set(0); while (!_clicked) { yield return(null); } // wait for punch anim to be done while (_clickAnim != null && _clickAnim.IsPlaying()) { yield return(null); } yield return(new WaitForSeconds(_finishPauseDuration)); result.Add(new GameActionParameterSuccessRate.Data((SurveySuccessRating)_currentNumber.Get())); complete(); }
protected override void OnGamePresentationUpdate() { _mouseWorldPosition.Set(Cache.PointerWorldPosition); if (_mouseInWorld.IsDirty || _mouseWorldPosition.IsDirty) { UpdateHoveredElements(); } _mouseWorldPosition.ClearDirty(); _mouseInWorld.ClearDirty(); }
public void UpdateRules(PlayerClassType currentPlayerClass) { playerClassType.Set(currentPlayerClass); if (playerClassType.ClearDirty()) { foreach (ContextRulePlayerClass rule in playerClassRules) { rule.CurrentPlayerClass = currentPlayerClass; ruleUpdater.DirtyRule(rule); } } }
protected override void OnGamePresentationUpdate() { if (SimWorld.TryGetComponent(SimEntity, out DoodleId doodleId)) { _doodleAssetGuid.Set(doodleId.Guid); } else { _doodleAssetGuid.Set(Guid.Empty); } if (_doodleAssetGuid.ClearDirty()) { _doodleAsset.Set(PlayerAssetManager.Instance.GetAsset <PlayerDoodleAsset>(_doodleAssetGuid.Get())); } if (_doodleAsset.ClearDirty()) { var previousDoodle = _doodleAsset.GetPrevious(); var newDoodle = _doodleAsset.Get(); if (previousDoodle != null) { previousDoodle.SpriteUpdated -= SetSprite; } if (newDoodle != null) { SetSprite(newDoodle.Sprite); newDoodle.SpriteUpdated += SetSprite; } else { SetSprite(null); } } }
protected override IEnumerator ExecuteRoutine() { if (!PreExecuteRoutine()) { yield break; } //////////////////////////////////////////////////////////////////////////////////////// // Send header to destination (contains essential details about the transfer) //////////////////////////////////////////////////////////////////////////////////////// NetMessageViaManualPacketsHeader header = new NetMessageViaManualPacketsHeader() { TransferId = _transferId, DataSize = _data.Length, PacketCount = _remainingUnacknowledgedPackets, Description = Description }; _sessionInterface.SendNetMessage(header, _connection); //////////////////////////////////////////////////////////////////////////////////////// // Update Transfer //////////////////////////////////////////////////////////////////////////////////////// _sessionInterface.RegisterNetMessageReceiver <NetMessagePacketACK>(OnPacketAcknowledged); while (_remainingUnacknowledgedPackets > 0) { // reset 'packetsSentThisFrame'. This value will ensure we don't send to many packets per second to our sessionInterface s_currentUnityFrame.Set(Time.frameCount); if (s_currentUnityFrame.ClearDirty()) { s_packetsSentThisFrame = 0; } // Update UpdateDataTransfer(); // wait a frame yield return(null); if (!IsRunning) { yield break; } } TerminateWithSuccess(); }
protected override void Awake() { _button.onClick.AddListener(OnReadyClicked); _updateTimer = UPDATE_DELAY; _viewState.Set(TurnState.NotMyTurn); // default value base.Awake(); }
private void HandleDirectionalMove() { fix2 input = fix2.zero; bool up = Input.GetKey(KeyCode.W); bool down = Input.GetKey(KeyCode.S); bool left = Input.GetKey(KeyCode.A); bool right = Input.GetKey(KeyCode.D); if (_muteVerticalInputUntilRelease && !up && !down) { _muteVerticalInputUntilRelease = false; } if (UIStateMachineController.Instance.CurrentSate.Type == UIStateType.Gameplay) { if (right) { input.x += 1; } if (left) { input.x += -1; } if (up && !_muteVerticalInputUntilRelease) { input.y += 1; } if (down && !_muteVerticalInputUntilRelease) { input.y += -1; } } _moveInput.Set(input); // NB: we only send an input if the direction changes. That way, we minimize network messages if (_moveInput.ClearDirty()) { SimPlayerInputMove simInput = new SimPlayerInputMove(_moveInput); SimWorld.SubmitInput(simInput); } }
protected override void OnUpdate() { var singleton = GetSingletonEntity <GridInfo>(); _gridInfoVersion.Set(EntityManager.GetChunk(singleton).GetComponentVersion(typeof(GridInfo))); if (_gridInfoVersion.ClearDirty()) { GridInfo = EntityManager.GetComponentData <GridInfo>(singleton); if (_tileReferencesBuffer.IsCreated) { _tileReferencesBuffer.Dispose(); } _tileReferencesBuffer = EntityManager.GetBufferReadOnly <GridTileReference>(GetSingletonEntity <GridInfo>()).ToNativeArray(Allocator.Persistent); } }
protected override void OnUpdate() { if (!SimAssetBankInstance.Ready) { return; } _simWorldReplaceVersion.Set(SimWorldAccessor.ReplaceVersion); _simWorldTickId.Set(SimWorldAccessor.ExpectedNewTickId); if (!_simWorldTickId.IsDirty && !_simWorldReplaceVersion.IsDirty) // only continue if sim has changed since last update { return; } _simWorldTickId.ClearDirty(); if (_simWorldReplaceVersion.ClearDirty()) // world replaced! { // update cached sim queries since world got replaced // NB: No need to dispose of these queries because the world gets disposed ... _updatedSimEntitiesQ = SimWorldAccessor.CreateEntityQuery(ComponentType.ReadOnly <SimAssetId>()); _updatedSimEntitiesQ.SetChangedVersionFilter(ComponentType.ReadOnly <SimAssetId>()); // Destroy all view DestroyAllViewEntities(); } else { // Destroy dangling view DestroyDanglingViewEntities(); } // update map UpdateSim2ViewMap(); // destroy then create view for entities that had their SimAssetId modified UpdateViewEntities(SimAssetBankInstance.GetJobLookup(), _updatedSimEntitiesQ); _updatedSimEntitiesQ.SetChangedFilterRequiredVersion(SimWorldAccessor.GlobalSystemVersion); _ecb.AddJobHandleForProducer(Dependency); }
public void UpdateSceneLoading() { if (_tickSystem.AvailableTicks.Count > 0) { SimTickData tick = _tickSystem.AvailableTicks.First(); _tickId.Set(tick.ExpectedNewTickId); // clear ignore list if tick has changed if (_tickId.ClearDirty()) { _inputsToIgnore.Clear(); } foreach (SimInputSubmission inputSubmission in tick.InputSubmissions) { if (inputSubmission.Input is SimCommandLoadScene loadSceneCommand) { if (!IsLoading(loadSceneCommand.SceneName) && !_inputsToIgnore.Contains(loadSceneCommand)) { // add input to 'ignore list' to make sure we don't load the same scenes over and over _inputsToIgnore.Add(loadSceneCommand); // prepare for entity injection (through convertion) _simulationWorldSystem.RegisterIncomingEntityInjection(loadSceneCommand.SceneName); // request load _sceneLoads.Add(SceneService.Load(loadSceneCommand.SceneName, LoadSceneMode.Additive, LocalPhysicsMode.Physics3D)); } } } } // clear when all scenes are loaded if (AreAllLoadsComplete()) { _sceneLoadsToUnregisterOnUpdate.AddRange(_sceneLoads); _sceneLoads.Clear(); } }
protected override void OnUpdate() { if (PlayerRepertoireSystem.Instance == null) { return; } // wait for level to be loaded before trying to spawn pawns, kinda hack ... if (!SimWorldAccessor.HasSingleton <GridInfo>()) { return; } _simTick.Set(SimWorldAccessor.ExpectedNewTickId); if (!_simTick.ClearDirty()) // makes sure we wait for sim update before sending new request { return; } // When we submit an input in the simulation, we have no guarantee that it will be processed in the next frame // This 'cooldown' mechanism ensures we don't ask for too many player creations if (_dontAskForPlayerCreateCooldownMap.Count > 0) { foreach (KeyValuePair <PlayerInfo, double> playerInCooldown in _dontAskForPlayerCreateCooldownMap) { if (playerInCooldown.Value < Time.ElapsedTime) { _dontAskForPlayerCreateCooldownMap.Remove(playerInCooldown.Key); break; } } } foreach (PlayerInfo playerInfo in PlayerRepertoireSystem.Instance.Players) { if (playerInfo.SimPlayerId == PersistentId.Invalid && AllowCreatePlayers) { Entity unassignedSimPlayer = GetUnassignedSimPlayer(); if (unassignedSimPlayer == Entity.Null) { // ask the simulation to create a new player // When we submit an input in the simulation, we have no guarantee that it will be processed in the next frame // This 'cooldown' mechanism ensures we don't ask for too many player creations if (!_dontAskForPlayerCreateCooldownMap.ContainsKey(playerInfo)) { SimWorldAccessor.SubmitInput(new SimInputPlayerCreate() { PlayerName = playerInfo.PlayerName }); _dontAskForPlayerCreateCooldownMap.Add(playerInfo, Time.ElapsedTime + 1); } } else { // assign the sim player to the player PersistentId simPlayerId = SimWorldAccessor.GetComponent <PersistentId>(unassignedSimPlayer); PlayerRepertoireMaster.Instance.AssignSimPlayerToPlayer(playerInfo.PlayerId, simPlayerId); } } } // Update Active Player State SimWorldAccessor.Entities .WithAll <PlayerTag>() .ForEach((Entity playerEntity, ref PersistentId playerID, ref Active isActive) => { PlayerInfo playerInfo = PlayerHelpers.GetPlayerFromSimPlayer(playerID); if (playerInfo != null && !isActive.Value) // player connected in game but not active in simulation { SimWorldAccessor.SubmitInput(new SimInputSetPlayerActive() { IsActive = true, PlayerID = playerID }); } else if (playerInfo == null && isActive.Value) // player disconnected but active in simulation { SimWorldAccessor.SubmitInput(new SimInputSetPlayerActive() { IsActive = false, PlayerID = playerID }); } }); }
private void OnMouseEnterWorld(BaseEventData eventData) { _mouseInWorld.Set(true); }
//public void SetMiniFormat(bool miniFormat) //{ // _miniFormat = miniFormat; // _channels.SetActive(!miniFormat); // _channelsToggle.SetActive(!miniFormat); // _buildIdText.gameObject.SetActive(!miniFormat); // _lines.gameObject.SetActive(!miniFormat); // _fullBackground.SetActive(!miniFormat); // _smallBackground.SetActive(miniFormat); // _inputField.text = ""; //} public void ConsoleUpdate() { if (IsAnyToggleKeyPressed()) { SetOpen(!IsOpen()); //if (IsOpen()) //{ // if (_miniFormat && _inputField.text.Length == 0) // { // SetMiniFormat(false); // } // else // { // SetOpen(false); // } //} //else //{ // SetOpen(true); // SetMiniFormat(true); //} } if (!IsOpen()) { return; } _canvasScaler.scaleFactor = s_consoleScale * 1.36f; // 1.36 being the 'default' scale // This is to prevent clicks outside input field from removing focus _inputField.ActivateInputField(); _inputText.Set(_inputField.text); if (string.IsNullOrEmpty(_inputField.text)) { _tryDisplaySuggestions.Set(false); } else if (_inputText.IsDirty && !string.IsNullOrEmpty(_inputText.Get())) { _tryDisplaySuggestions.Set(true); } UpdateSuggestionList(); if (!_suggestionList.gameObject.activeSelf) { if (Input.GetKeyDown(KeyCode.UpArrow)) { _inputField.text = GameConsole.HistoryUp(); _wantedCaretPosition = _inputField.text.Length; _inputText.Set(_inputField.text); _inputText.ClearDirty(); } else if (Input.GetKeyDown(KeyCode.DownArrow)) { _inputField.text = GameConsole.HistoryDown(); _inputField.caretPosition = _inputField.text.Length; _inputText.Set(_inputField.text); _inputText.ClearDirty(); } } else { GameConsole.HistoryDownCompletely(); } if (_submitCommandKeys.Any(k => Input.GetKeyDown(k))) { OnSubmit(_inputField.text); } HandleScrollInput(); }