public void Run() { right = camera.right; forward = camera.forward; foreach (var i in _filter) { //Get player Entity var entity = _filter.GetEntity(i); // Get data var direction = _filter.Get1(i).Value; var transform = _filter.Get2(i).Value; var up = transform.up; // Calculate and aply translatin ref var physicTranslation = ref entity.Get <PhysicTranslation>(); var translation = CalculateTranslation(up, direction); physicTranslation.Value = translation * (entity.Has <RunTag>() && !entity.Has <TiredTag>() ? fastDeltaSpeed : slowDeltaSpeed); // Change Entity to View Entity entity = _filter.Get3(i).Entity; // Update target rotation var rotation = quaternion.LookRotation(translation, up); ref var target = ref entity.Get <TargetRotation>();
void IEcsRunSystem.Run() { // Timer if (_timer > 0) { _timer -= Time.deltaTime; return; } else { _timer = TimeUpdateSec; } // CreateMobsRequest var powerNeed = _filterScore.Get1(0).Value * 0.1f + 10f; var powerMobSum = GetPowerMobsInGame(); var powerAdd = powerNeed - powerMobSum; if (powerAdd > 0) { var entity = _world.NewEntity(); entity.Get <CreateMobsRequest>().PowerMobs = powerAdd; } }
void IEcsRunSystem.Run() { if (!_movingFilter.IsEmpty()) { return; } foreach (var i in _mergeBubbleFilter) { var value = _mergeBubbleFilter.Get1(i).Value; var position = Hex.ToWorldPosition(_mergeBubbleFilter.Get3(i).Value); var text = Object.Instantiate(_config.MergePopupText, position, Quaternion.identity); if (value < 1024) { text._text.SetText("{0}", value); } else { text._text.SetText("{0}K", value / 1024f); } } }
void IEcsRunSystem.Run() { if (!MultiplayerManager.IsMaster) { return; } foreach (var p in players) { ref var player = ref players.Get1(p); if (!player.view.GetComponent <PhotonView>()) { continue; } if (players.Get2(p).enemyTarget&& player.cooldownRate >= player.cooldownValue) { player.view.Fire(player.damage); player.cooldownRate = 0; //Debug.Log($"{player.cooldownValue} -+-+- {player.view.photonView.ViewID}"); } }
public void Run() { if (_activateFilter.IsEmpty()) { return; } foreach (var idx in _activateFilter) { ref var entity = ref _activateFilter.GetEntity(idx); var sceneController = _activateFilter.Get1(idx).Scene; var isMain = _activateFilter.Get3(idx).IsMain; entity.Del <IsSceneInactiveComponent>(); entity.Get <IsSceneActiveComponent>(); entity.Get <SceneChangedStateComponent>(); sceneController.ShowContent(); if (isMain) { sceneController.SetAsMain(); } }
private void _DeactivateScene() { foreach (var idx in _deactivateFilter) { var eventComponent = _deactivateFilter.Get1(idx); foreach (var i in _activeScenesFilter) { var scene = _activeScenesFilter.Get1(i).Scene; if (!scene.SceneName.Equals(eventComponent.Name)) { continue; } _activeScenesFilter.GetEntity(i).Get <DeactivateSceneComponent>(); // idea behind this 'break' to reduce complexity of this loop, // but with this it is impossible to mark scenes with the same name, // which is possible if the same scene was loaded multiple times. // break; } } }
void IEcsRunSystem.Run() { var deltaTime = Time.deltaTime; foreach (var i in filter) { ref var movable = ref filter.Get1(i); var rawDirectionVector = movable.Destination - movable.Transform.position; var direction = rawDirectionVector.normalized; var distance = rawDirectionVector.sqrMagnitude; if (distance <= movable.StopSqrDistance) { continue; } movable.Transform.position += deltaTime * movable.Data.MoveSpeed * direction; if (movable.LookInMoveDirection) { movable.Transform.rotation = Quaternion.RotateTowards(movable.Transform.rotation, Quaternion.LookRotation(direction), movable.Data.RotationSpeed * deltaTime); } }
void IEcsRunSystem.Run() { if (!_restartEventFilter.IsEmpty()) { foreach (var index in _filter) { ref var turtlePath = ref _filter.Get1(index); var paths = turtlePath.Path; paths.Clear(); _direction = new RightDirectionState(); for (var i = 0; i < _turtleConfiguration.PathsCount; i++) { paths.Add(GeneratePath()); } var entity = _filter.GetEntity(index); ref var updateTextEvent = ref entity.Get <UpdateTextEvent>(); updateTextEvent.Text = string.Join("", paths[0]); turtlePath.CurrentPath = 0; turtlePath.CurrentSymbol = 0; }
public void Run() { var horizontal = Input.GetAxis("Horizontal"); var vertical = Input.GetAxis("Vertical"); var rotation_y = Input.GetAxis("Mouse X"); var rotation_x = -Input.GetAxis("Mouse Y"); var isShooting = Input.GetMouseButtonDown(0); var isJump = Input.GetKeyDown(KeyCode.Space); foreach (var i in inputEventsFilter) { ref var inputEvent = ref inputEventsFilter.Get1(i); inputEvent.isShooting = isShooting; inputEvent.isJump = isJump; inputEvent.vertical = vertical; inputEvent.horizontal = horizontal; inputEvent.mouseRotationX = rotation_y; inputEvent.mouseRotationY = rotation_x; }
public void Run() { foreach (var index in _eventFilter) { var coin = _coinFilter.FirstOrDefault(x => x.Target == _eventFilter.Get1(index).Target); if (coin == null) { continue; } var pacman = _pacmanFilter.FirstOrDefault(); if (pacman == null) { continue; } ref var pacmanComponent = ref pacman.Entity.Set <PacmanComponent>(); pacmanComponent.Points += coin.Component.Points; Object.Destroy(coin.Component.Target); coin.Entity.Destroy(); }
public void Run() { foreach (var i in filter) { ref var mess = ref filter.Get1(i); if (commands.IsCommand(mess.FirstWord, commands.Enter) == false) { continue; } if (runtimeData.IsEscapedPlayer(mess.Sender)) { SendMessage($"{gameData.Localizations.TwitchUserPrefix}{mess.Sender} {gameData.Localizations.AlreadyEscaped}"); continue; } if (runtimeData.ContainsPlayer(mess.Sender)) { SendMessage($"{gameData.Localizations.TwitchUserPrefix}{mess.Sender} {gameData.Localizations.AlreadySpawned}"); continue; } var ent = world.NewEntity(); ref var spawn = ref ent.Set <PlayerSpawnComponent>();
void IEcsRunSystem.Run() { foreach (var i in _filter) { ref var blueprintRefComponent = ref _filter.Get1(i); ref var ownerComponent = ref _filter.Get3(i);
public void Run() { foreach (var i in filter) { ref var player = ref filter.Get1(i); ref var playerEnt = ref filter.GetEntity(i);
private void AutoReload(EcsFilter <ReloadGunComponent, AmmoCapacityComponent> .Exclude <TimeRGunReloadComponent, AmmoComponent> filterGunsNoAmmo) { foreach (var i in filterGunsNoAmmo) { ref var setupComponent = ref filterGunsNoAmmo.Get1(i); ref var entity = ref filterGunsNoAmmo.GetEntity(i);
void IEcsRunSystem.Run() { foreach (var i in _filter) { ref var block = ref _filter.Get1(i); ref var positions = ref _filter.Get2(i).Positions;
public void Run() { foreach (var i in _filter) { ref var cubeView = ref _filter.Get1(i).Value; ref var targetPosition = ref _filter.Get2(i).TargetPosition.value;
public void Run() { foreach (var i in filter) { ref var skin = ref filter.Get1(i); ref var changer = ref filter.Get2(i);
public void Run() { foreach (var i in _actors) { ref var actor = ref _actors.Get1(i); ref var position = ref _actors.Get2(i);
public void Run() { foreach (var i in _bullets) { ref var bullet = ref _bullets.Get1(i); ref var position = ref _bullets.Get2(i);
void IEcsRunSystem.Run() { foreach (var i in _damageFilter) { ref var makeDamageRequest = ref _damageFilter.Get1(i); ref var healthCurrent = ref _damageFilter.Get2(i);
void IEcsRunSystem.Run() { foreach (var gc in jobs.Values.ToArray()) { if (gc.handle.IsCompleted) { gc.handle.Complete(); var chunk = gc.chunk; gc.data.CopyTo(chunk.data); for (int x = chunk.x - 1; x <= (chunk.x + 0x10); x++) { for (int z = (int)WorldLayerEnum.First; z <= (int)WorldLayerEnum.Last; z++) { SetBlockUpdate(x, chunk.y - 1, z); SetBlockUpdate(x, chunk.y + 0x10, z); } } for (int y = chunk.y - 1; y <= (chunk.y + 0x10); y++) { for (int z = (int)WorldLayerEnum.First; z <= (int)WorldLayerEnum.Last; z++) { SetBlockUpdate(chunk.x - 1, y, z); SetBlockUpdate(chunk.x + 0x10, y, z); } } for (int i = 0; i < gc.chunk.data_update.Length; i++) { chunk.data_update[i] = BlockFlag.Update; } jobs.Remove(gc.chunk); chunk.flag |= ChunkFlag.Loaded | ChunkFlag.Update; gc.Dispose(); chunk.count = chunk.data.Where(d => d.id == BlockType.Stone).Count(); } } if (_filter.IsEmpty()) { return; } foreach (var i in _filter) { ref var chunk = ref _filter.Get1(i).Value; if ((chunk.flag & ChunkFlag.Generate) == ChunkFlag.Generate) { var container = new ChunkGenerateContainer { chunk = chunk, data = new NativeArray <BlockData>(chunk.data, Allocator.TempJob) }; var job = new ChunkGenerateJob { x = chunk.x, y = chunk.y, z = chunk.z, data = container.data }; container.handle = job.Schedule(); jobs.Add(chunk, container); chunk.flag &= ~ChunkFlag.Generate; } }
void IEcsRunSystem.Run() { foreach (var i in ecsFilter_1) { ecsFilter_1.Get1(i).time += Time.deltaTime; if (ecsFilter_1.Get1(i).time > ecsFilter_1.Get1(i).dTime) { float randTime = Random.Range(-ecsFilter_1.Get1(i).dTime / 2, ecsFilter_1.Get1(i).dTime / 2); ecsFilter_1.Get1(i).time = randTime; int who = Random.Range(0, 3); GameObject obs = ecsFilter_1.Get1(i).obstacles[who]; var obstacle = _world.NewEntity(); ref var obj = ref obstacle.Get <ObstaclesComponent>(); obj.defoultSpeed = ecsFilter_1.Get1(i).speedObstacle; float dPos = 0; int pos = Random.Range(0, 1000); if (pos < 333) { dPos = ecsFilter_1.Get1(i).distance; } else if (pos < 666) { dPos = -ecsFilter_1.Get1(i).distance; } Vector3 d = new Vector3(dPos, 0, 0); obs = GameObject.Instantiate(obs, ecsFilter_1.Get1(i).transform.position + d, Quaternion.identity) as GameObject; obs.transform.eulerAngles = new Vector3(0, -90, 0); obj.rb = obs.GetComponent <Rigidbody>(); obs.AddComponent <CollisionEmitter>().world = _world; if (ecsFilter_1.Get1(i).dTime > 0.6f) { ecsFilter_1.Get1(i).dTime -= ecsFilter_1.Get1(i).complexityDeltaTime; } ecsFilter_1.Get1(i).speedObstacle += 1; foreach (var x in _record) { _record.Get1(x).deltaCoins += 1; } foreach (var j in ecsFilter_2) { ecsFilter_2.Get1(j).defoultSpeed = ecsFilter_1.Get1(i).speedObstacle; } } }
public void Run() { foreach (var index in _filter) { ref Npc npc = ref _filter.Get1(index); ref RouteMover routeMover = ref _filter.Get3(index);
public void ProcessGizmos() { var selected = _guiService.SelectedEntity; if (selected != default && selected.Has <TransformComponent>()) { foreach (var camera in _cameras) { ref var cam = ref _cameras.Get1(camera); if (cam.Camera.Active && _guiService.GizmoType.HasValue) { if (duplicated && (!InputManager.Instance.GetKeyDown(KeyCodes.AltLeft) || InputManager.Instance.GetMouseButtonUp(MouseButtonCodes.Left))) { duplicated = false; } ImGuizmo.SetID(camera); ImGuizmo.SetOrthographic(cam.Camera.ProjectionType == BootEngine.Renderer.Cameras.ProjectionType.Orthographic); ImGuizmo.SetDrawlist(ImGui.GetWindowDrawList()); float windowWidth = ImGui.GetWindowWidth(); float windowHeight = ImGui.GetWindowHeight(); ImGuizmo.SetRect(ImGui.GetWindowPos().X, ImGui.GetWindowPos().Y, windowWidth, windowHeight); bool snap = InputManager.Instance.GetKeyDown(KeyCodes.LControl); float snapValue = .1f; if (_guiService.GizmoType == OPERATION.ROTATE) { snapValue = 45f; } float[] snapValues = new float[] { snapValue, snapValue, snapValue }; ref var tc = ref selected.Get <TransformComponent>(); var rotTmp = MathUtil.Rad2Deg(tc.Rotation); float[] pos = new float[] { tc.Translation.X, tc.Translation.Y, tc.Translation.Z }; float[] rot = new float[] { rotTmp.X, rotTmp.Y, rotTmp.Z }; float[] sca = new float[] { tc.Scale.X, tc.Scale.Y, tc.Scale.Z }; float[] transform = new float[16]; ImGuizmo.RecomposeMatrixFromComponents(ref pos[0], ref rot[0], ref sca[0], ref transform[0]); // using the component's transform breaks guizmos for some reason // TODO: investigate //transform = tc.Transform.ToFloatArray(); ref var cameraTc = ref _cameras.Get2(camera); Matrix4x4.Invert(cameraTc.Transform, out Matrix4x4 cameraViewMat); float[] cameraView = cameraViewMat.ToFloatArray(); float[] cameraProj; if (cam.Camera.SwapYAxis) { // de-swapping Y axis for gizmo rendering cameraProj = (cam.Camera.ProjectionMatrix * new Matrix4x4( 1, 0, 0, 0, 0, -1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1)).ToFloatArray(); } else { cameraProj = cam.Camera.ProjectionMatrix.ToFloatArray(); } float[] deltaTransform = new float[16]; if (snap) { ImGuizmo.Manipulate(ref cameraView[0], ref cameraProj[0], _guiService.GizmoType.Value, MODE.LOCAL, ref transform[0], ref deltaTransform[0], ref snapValues[0]); } else { ImGuizmo.Manipulate(ref cameraView[0], ref cameraProj[0], _guiService.GizmoType.Value, MODE.LOCAL, ref transform[0], ref deltaTransform[0]); } if (ImGuizmo.IsOver() && ImGuizmo.IsUsing()) { if (InputManager.Instance.GetKeyDown(KeyCodes.AltLeft) && !duplicated) { // copy current entity _guiService.SelectedEntity = _guiService.SelectedEntity.Copy(); ref var tag = ref _guiService.SelectedEntity.Get <TagComponent>(); #pragma warning disable S1643 // Strings should not be concatenated using '+' in a loop tag.Tag += " (Copy)"; #pragma warning restore S1643 // Strings should not be concatenated using '+' in a loop duplicated = true; } float[] translation = new float[3]; float[] rotation = new float[3]; float[] scale = new float[3]; switch (_guiService.GizmoType) { case OPERATION.TRANSLATE: ImGuizmo.DecomposeMatrixToComponents(ref deltaTransform[0], ref translation[0], ref rotation[0], ref scale[0]); tc.Translation += new Vector3(translation[0], translation[1], translation[2]); break; case OPERATION.ROTATE: ImGuizmo.DecomposeMatrixToComponents(ref deltaTransform[0], ref translation[0], ref rotation[0], ref scale[0]); tc.Rotation -= MathUtil.Deg2Rad(new Vector3(rotation[0], rotation[1], rotation[2])); break; case OPERATION.SCALE: // for some reason, scale part from deltaTransform does not return deltaScale ImGuizmo.DecomposeMatrixToComponents(ref transform[0], ref translation[0], ref rotation[0], ref scale[0]); tc.Scale = new Vector3(scale[0], scale[1], scale[2]); break; } }
void IEcsRunSystem.Run() { foreach (var s in spawns) { ref var spawn = ref spawns.Get1(s); var hits = Physics2D.CircleCastAll(spawn.pos, 1.58f, Vector2.zero); bool isIntersection = false; //=========================================== spawn.view.captureValue = spawn.captureValue; //=========================================== List <TeamNum> intersectTeams = new List <TeamNum>(); int idx = 0; foreach (var hit in hits) { idx++; if (!hit.transform.GetComponent <Player>()) { continue; } isIntersection = true; //Находим сущности игроков исходя из имеющихся view игроков в пересечении foreach (var p in players) { ref var player = ref players.Get1(p); var playerIsFound = hit.transform.GetComponent <Player>() == player.view; if (playerIsFound) { intersectTeams.Add(player.teamNum); intersectTeams = intersectTeams.Distinct().ToList(); } } if (idx < hits.Length) { continue; } foreach (var p in players) { ref var player = ref players.Get1(p); var playerIsFound = hit.transform.GetComponent <Player>() == player.view; if (playerIsFound) { //Debug.Log($"{teams[player.teamNum]} -+-+-- Тип спауна {spawn.spawnType} -+-+-+ Тима {player.teamNum}"); //Debug.Log($"{intersectTeams.Count} - каунт хуянт {idx}"); ref var spawnEntity = ref spawns.GetEntity(s); if (spawnEntity.Has <CrossCaptureTag>()) { if (intersectTeams.Count > 1) { continue; } else { spawnEntity.Del <CrossCaptureTag>(); var col = spawn.view.GetCurColor(spawn.spawnType); ChangeColor(ref spawn, col, col); } } if (intersectTeams.Count > 1) { spawnEntity.Get <CrossCaptureTag>(); continue; } if (teams[player.teamNum] == spawn.spawnType) { //Debug.Log($"{teams[player.teamNum]} ^^^^ {spawn.spawnType}"); if (spawn.captureValue < 1) { spawn.captureValue += Time.deltaTime * captureSpeed; Color32 cur = Color.white; Color32 tar = spawn.view.GetCurColor(teams[player.teamNum]); ChangeColor(ref spawn, cur, tar); spawn.lastCaptureColor = spawn.view.GetCurColor(teams[player.teamNum]); } else { continue; } } //Debug.Log($"{teams[player.teamNum]} -+-+-- {spawn.spawnType}"); if (spawn.captureValue > 0 && spawn.spawnType != SpawnType.Neutral && teams[player.teamNum] != spawn.spawnType) { spawn.captureValue -= Time.deltaTime * captureSpeed; Color32 cur = spawn.view.GetCurColor(spawn.spawnType); Color32 tar = Color.white; ChangeColor(ref spawn, tar, cur); } if (spawn.captureValue <= 0 && spawn.spawnType != SpawnType.Neutral) { spawn.spawnType = SpawnType.Neutral; spawn.lastCaptureColor = spawn.view.GetCurColor(teams[player.teamNum]); } if (spawn.captureValue < 1 && spawn.spawnType == SpawnType.Neutral) { if (spawn.lastCaptureColor == Color.white || spawn.lastCaptureColor == spawn.view.GetCurColor(teams[player.teamNum])) { spawn.captureValue += Time.deltaTime * captureSpeed; Color32 cur = Color.white; Color32 tar = spawn.view.GetCurColor(teams[player.teamNum]); ChangeColor(ref spawn, cur, tar); spawn.lastCaptureColor = spawn.view.GetCurColor(teams[player.teamNum]); if (spawn.captureValue >= 1 && teams[player.teamNum] != spawn.spawnType) { spawn.spawnType = teams[player.teamNum]; //spawn.lastCaptureColor = spawn.view.GetCurColor(teams[player.teamNum]); } } else { spawn.captureValue -= Time.deltaTime * captureSpeed; Color32 cur = Color.white; Color32 tar = spawn.lastCaptureColor;//view.GetCurColor(teams[player.teamNum]); ChangeColor(ref spawn, cur, tar); if (spawn.captureValue <= 0) { spawn.lastCaptureColor = Color.white; } } } }
void IEcsRunSystem.Run() { foreach (var i in filter) { ref Components.InputComponent input = ref filter.Get1(i); ref Components.MovementPlayerComponent movement = ref filter.Get2(i);
void IEcsRunSystem.Run() { foreach (var i in _filter) { ref var moveComponent = ref _filter.Get1(i); ref var blockComponent = ref _filter.Get2(i);
void IEcsRunSystem.Run() { foreach (var i in _filter) { ref var blueprintRefComponent = ref _filter.Get1(i); ref var powerGameDesign = ref _filter.Get2(i);
public void Run() { foreach (var i in filter) { ref var player = ref filter.Get1(i); ref var moving = ref filter.Get2(i);
public void Run(float delta) { foreach (int i in _filter) { ref PlayerInputComponent playerInputComponent = ref _filter.Get1(i); ref MoveableComponent moveableComponent = ref _filter.Get2(i);