// public override GameState PastState { get; set; } // public override GameState PresentState { get; set; } public override void Execute(ServerGameEntity damageEntity) { if (!damageEntity.hasTransform) { return; } if (!damageEntity.hasDamage) { return; } var testTransform = damageEntity.transform.value; if (testTransform == null) { log.Error("Transform пуст"); return; } Vector3 currentPosition = damageEntity.transform.value.position; Vector3 direction = damageEntity.transform.value.rotation * Vector3.forward; Vector3 velocity = damageEntity.rigidbody.value.velocity * tickDeltaTimeStorage.GetDeltaTimeSec(); //Есть столкновение? bool collisionOccurred = physicsRaycaster .Raycast(currentPosition, direction, velocity.magnitude, out RaycastHit raycastHit); if (!collisionOccurred) { return; } EntityLink entityLink = raycastHit.transform.gameObject.GetEntityLink(); ServerGameEntity targetEntity = (ServerGameEntity)entityLink.entity; if (targetEntity == null) { return; } ushort entityId = targetEntity.id.value; //Проверка попадания по самому себе if (damageEntity.parentWarship.entity.id.value == entityId) { log.Error($"Попадание по самому себе parentId = {entityId}"); return; } ServerGameEntity hitEntity = gameContext.CreateEntity(); hitEntity.AddHit(damageEntity, targetEntity); }
public void Execute() { foreach (var inputEntity in inputGroup) { if (!inputEntity.hasAttack) { log.Error("Нет компонента атаки."); continue; } float desiredAngle = inputEntity.attack.direction; if (float.IsNaN(desiredAngle)) { log.Info("Неправильное значение угла атаки."); continue; } ushort playerId = inputEntity.playerInput.playerEntityId; ServerGameEntity playerEntity = gameContext.GetEntityWithPlayer(playerId); if (playerEntity == null) { log.Error($"Нет такого игрока. {nameof(playerId)} {playerId}"); continue; } if (!playerEntity.hasRigidbody) { log.Error($"Нет rigidbody"); continue; } if (float.IsNaN(desiredAngle)) { playerEntity.rigidbody.value.angularVelocity = Vector3.zero; continue; } if (!playerEntity.hasAngularVelocity) { log.Error("У сущности должен быть AngularVelocity"); continue; } float deltaTimeSec = tickDeltaTimeStorage.GetDeltaTimeSec(); // float angularVelocity = playerEntity.angularVelocity.value; float angularVelocity = 90; physicsRotationManager.ApplyRotation(playerEntity.rigidbody.value, desiredAngle, angularVelocity, deltaTimeSec); } }
public void Execute() { var entities = cooldownGroup.GetEntities(); for (var index = 0; index < entities.Length; index++) { var entity = entities[index]; float cooldownInSec = entity.cannonCooldown.value; if (cooldownInSec > 0) { // Debug.LogError("Уменьшение времен перезарядки"); entity.cannonCooldown.value = cooldownInSec - tickDeltaTimeStorage.GetDeltaTimeSec(); } else { // Debug.LogError("Удаление времени перезарядки"); entity.RemoveCannonCooldown(); } } }
public void Execute() { float deltaTime = tickDeltaTimeStorage.GetDeltaTimeSec(); scene.GetPhysicsScene().Simulate(deltaTime); }