public void StartBurrowing() { //GR: Added simple check so burrowing functions should happen only when on Voxel physics. //Not sure though if this check should be somewhere else (e.g. behaviour Tree) var result = Sandbox.Engine.Physics.MyPhysics.CastRay(AgentBot.BotEntity.WorldMatrix.Translation - 3 * AgentBot.BotEntity.WorldMatrix.Up, AgentBot.BotEntity.WorldMatrix.Translation + 3 * AgentBot.BotEntity.WorldMatrix.Up, Sandbox.Engine.Physics.MyPhysics.CollisionLayers.NoVoxelCollisionLayer); if (result != null && (result as VRage.Game.ModAPI.IHitInfo).HitEntity != AgentBot.BotEntity) { return; } if (AgentBot.AgentEntity.UseNewAnimationSystem) { MySpiderLogic.TriggerAnimationEvent(AgentBot.AgentEntity.EntityId, "burrow"); if (Sync.IsServer) { MyMultiplayer.RaiseStaticEvent(x => MySpiderLogic.TriggerAnimationEvent, AgentBot.AgentEntity.EntityId, "burrow"); } } else { if (AgentBot.AgentEntity.HasAnimation("Burrow")) { AgentBot.AgentEntity.PlayCharacterAnimation("Burrow", MyBlendOption.Immediate, MyFrameOption.Default, 0.0f, 1, sync: true); AgentBot.AgentEntity.DisableAnimationCommands(); } } AgentBot.AgentEntity.SoundComp.StartSecondarySound("ArcBotSpiderBurrowIn", true); m_burrowing = true; m_burrowStart = MySandboxGame.TotalGamePlayTimeInMilliseconds; }
public void StartDeburrowing() { //GR: Added simple check so burrowing functions should happen only when on Voxel physics. //Not sure though if this check should be somewhere else (e.g. behaviour Tree) var result = Sandbox.Engine.Physics.MyPhysics.CastRay(AgentBot.BotEntity.WorldMatrix.Translation - 3 * AgentBot.BotEntity.WorldMatrix.Up, AgentBot.BotEntity.WorldMatrix.Translation + 3 * AgentBot.BotEntity.WorldMatrix.Up, Sandbox.Engine.Physics.MyPhysics.CollisionLayers.NoVoxelCollisionLayer); if (result != null && (result as VRage.Game.ModAPI.IHitInfo).HitEntity != AgentBot.BotEntity) { return; } if (AgentBot.AgentEntity.UseNewAnimationSystem) { MySpiderLogic.TriggerAnimationEvent(AgentBot.AgentEntity.EntityId, "deburrow"); if (Sync.IsServer) { MyMultiplayer.RaiseStaticEvent(x => MySpiderLogic.TriggerAnimationEvent, AgentBot.AgentEntity.EntityId, "deburrow"); } } m_deburrowing = true; m_deburrowStart = MySandboxGame.TotalGamePlayTimeInMilliseconds; CreateBurrowingParticleFX(); m_deburrowAnimationStarted = false; m_deburrowSoundStarted = false; }
public void StartDeburrowing() { if (AgentBot.AgentEntity.UseNewAnimationSystem) { MySpiderLogic.TriggerAnimationEvent(AgentBot.AgentEntity.EntityId, "deburrow"); if (Sync.IsServer) { MyMultiplayer.RaiseStaticEvent(x => MySpiderLogic.TriggerAnimationEvent, AgentBot.AgentEntity.EntityId, "deburrow"); } } m_deburrowing = true; m_deburrowStart = MySandboxGame.TotalGamePlayTimeInMilliseconds; CreateBurrowingParticleFX(); m_deburrowAnimationStarted = false; m_deburrowSoundStarted = false; }
public void StartBurrowing() { if (AgentBot.AgentEntity.UseNewAnimationSystem) { MySpiderLogic.TriggerAnimationEvent(AgentBot.AgentEntity.EntityId, "burrow"); if (Sync.IsServer) { MyMultiplayer.RaiseStaticEvent(x => MySpiderLogic.TriggerAnimationEvent, AgentBot.AgentEntity.EntityId, "burrow"); } } else { if (AgentBot.AgentEntity.HasAnimation("Burrow")) { AgentBot.AgentEntity.PlayCharacterAnimation("Burrow", MyBlendOption.Immediate, MyFrameOption.Default, 0.0f, 1, sync: true); AgentBot.AgentEntity.DisableAnimationCommands(); } } AgentBot.AgentEntity.SoundComp.StartSecondarySound("ArcBotSpiderBurrowIn", true); m_burrowing = true; m_burrowStart = MySandboxGame.TotalGamePlayTimeInMilliseconds; }
public override void Update() { base.Update(); if (IsAttacking) { int attackTime = MySandboxGame.TotalGamePlayTimeInMilliseconds - m_attackStart; if (attackTime > ATTACK_LENGTH) { IsAttacking = false; MyCharacter botEntity = m_bot.AgentEntity; if (botEntity != null) { botEntity.EnableAnimationCommands(); } } else if (attackTime > 500 && m_bot.AgentEntity.UseNewAnimationSystem && !m_attackPerformed) { MySpiderLogic.TriggerAnimationEvent(m_bot.AgentEntity.EntityId, "attack"); if (Sync.IsServer) { MyMultiplayer.RaiseStaticEvent(x => MySpiderLogic.TriggerAnimationEvent, m_bot.AgentEntity.EntityId, "attack"); } m_attackPerformed = true; } else if (attackTime > 500 && !m_attackPerformed) { MyCharacter botEntity = m_bot.AgentEntity; if (botEntity != null) { Vector3D attackPosition = botEntity.WorldMatrix.Translation + botEntity.PositionComp.WorldMatrix.Forward * 2.5 + botEntity.PositionComp.WorldMatrix.Up * 1.0; m_attackBoundingSphere = new BoundingSphereD(attackPosition, 1.1); m_attackPerformed = true; List <MyEntity> hitEntities = MyEntities.GetTopMostEntitiesInSphere(ref m_attackBoundingSphere); foreach (var hitEntity in hitEntities) { //AttackEntity(hitEntity); if (hitEntity is MyCharacter && hitEntity != botEntity) { var character = hitEntity as MyCharacter; if (character.IsSitting) { continue; } var characterVolume = character.PositionComp.WorldVolume; double touchDistSq = m_attackBoundingSphere.Radius + characterVolume.Radius; touchDistSq = touchDistSq * touchDistSq; if (Vector3D.DistanceSquared(m_attackBoundingSphere.Center, characterVolume.Center) > touchDistSq) { continue; } if (character.IsDead) { var inventory = character.GetInventory(); if (inventory == null) { continue; } if (m_bot.AgentEntity == null) { continue; } var spiderInventory = m_bot.AgentEntity.GetInventory(); if (spiderInventory == null) { continue; } MyInventory.TransferAll(inventory, spiderInventory); } else { character.DoDamage(ATTACK_DAMAGE_TO_CHARACTER, MyDamageType.Bolt, updateSync: true, attackerId: botEntity.EntityId); } } else if (hitEntity is MyCubeGrid && hitEntity.Physics != null) { var grid = hitEntity as MyCubeGrid; m_tmpBlocks.Clear(); grid.GetBlocksInsideSphere(ref m_attackBoundingSphere, m_tmpBlocks); foreach (var block in m_tmpBlocks) { block.DoDamage(ATTACK_DAMAGE_TO_GRID, MyDamageType.Bolt); } m_tmpBlocks.Clear(); } } hitEntities.Clear(); } } if (attackTime > 500) { //MyRenderProxy.DebugDrawSphere(m_attackBoundingSphere.Center, (float)m_attackBoundingSphere.Radius, Color.Red, 1.0f, false); } } }