Skip to content

Commit

Permalink
add character collision damage disabler
Browse files Browse the repository at this point in the history
  • Loading branch information
InvalidArgument3 committed Jun 26, 2024
1 parent bd8d00a commit f799708
Show file tree
Hide file tree
Showing 3 changed files with 90 additions and 33 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
using Sandbox.Common.ObjectBuilders;
using Sandbox.Game.Entities;
using Sandbox.ModAPI;
using VRage.Game;
using VRage.Game.Components;
using VRage.Game.ModAPI;
using VRage.Utils;

namespace DisablePlayerCollisionDamageMod
{
[MySessionComponentDescriptor(MyUpdateOrder.NoUpdate)]
public class DisablePlayerCollisionDamage : MySessionComponentBase
{
public override void BeforeStart()
{
// Register the damage handler
MyAPIGateway.Session.DamageSystem.RegisterBeforeDamageHandler(0, BeforeDamageApplied);
}

protected override void UnloadData()
{
// No need to unregister as there's no unregister method
}

private void BeforeDamageApplied(object target, ref MyDamageInformation info)
{
// Check if the target is a player character
if (target is IMyCharacter)
{
// Show the damage type in a notification
//MyAPIGateway.Utilities.ShowNotification($"DamageType: {info.Type}", 2000, MyFontEnum.Green);

// Check if the damage type is collision
if (info.Type == MyDamageType.Environment || info.Type == MyDamageType.Fall)
{
// Set damage amount to zero for collision damage
info.Amount = 0f;
}
}
}
}
}
81 changes: 48 additions & 33 deletions Dynamic Asteroids/DynamicAsteroidsClassDiagram.cd
Original file line number Diff line number Diff line change
@@ -1,28 +1,29 @@
<?xml version="1.0" encoding="utf-8"?>
<ClassDiagram MajorVersion="1" MinorVersion="1" GroupingSetting="Access">
<Comment CommentText="Networking">
<Position X="15.97" Y="0.5" Height="0.334" Width="1.7" />
</Comment>
<Comment CommentText="CONFIG">
<Position X="21.901" Y="0.606" Height="0.352" Width="1.7" />
</Comment>
<Class Name="DynamicAsteroids.AsteroidEntities.AsteroidEntity" BaseTypeListCollapsed="true">
<Position X="8.5" Y="8.25" Width="2.25" />
<ClassDiagram MajorVersion="1" MinorVersion="1">
<Class Name="DynamicAsteroids.Data.Scripts.DynamicAsteroids.AsteroidEntities.AsteroidEntity" BaseTypeListCollapsed="true">
<Position X="6.75" Y="1" Width="2.25" />
<TypeIdentifier>
<HashCode>CQABgCAABBAA4AgQgAACAAAIIABAg0AAAQACAQAAAAA=</HashCode>
<FileName>Data\Scripts\DynamicAsteroids\AsteroidEntities\AsteroidEntity.cs</FileName>
</TypeIdentifier>
<Lollipop Position="0.2" Collapsed="true" />
</Class>
<Class Name="AsteroidState">
<Position X="8.25" Y="4" Width="1.5" />
<Class Name="DynamicAsteroids.Data.Scripts.DynamicAsteroids.AsteroidEntities.AsteroidSettings">
<Position X="18" Y="0.5" Width="2.75" />
<TypeIdentifier>
<HashCode>AAAAAAAAAAIAgAAgAAAAAAAAAAAAAAAAAQAAAAAAAAA=</HashCode>
<FileName>Data\Scripts\DynamicAsteroids\AsteroidState.cs</FileName>
<HashCode>DGBCgIMGAIAIAIBmEkEADBWQOtQJQADGlCQ0ACjUAAA=</HashCode>
<FileName>Data\Scripts\DynamicAsteroids\AsteroidEntities\AsteroidSettings.cs</FileName>
</TypeIdentifier>
</Class>
<Class Name="DynamicAsteroids.Data.Scripts.DynamicAsteroids.AsteroidEntities.SpawnableArea">
<Position X="9.75" Y="0.5" Width="1.5" />
<TypeIdentifier>
<HashCode>AAAIAAACAAAAAAAAABAAAAQAAAAAAAAAAAAAAAAAABA=</HashCode>
<FileName>Data\Scripts\DynamicAsteroids\AsteroidEntities\AsteroidSettings.cs</FileName>
</TypeIdentifier>
</Class>
<Class Name="DynamicAsteroids.AsteroidNetworkMessageContainer">
<Position X="15" Y="1.25" Width="3.5" />
<Class Name="DynamicAsteroids.Data.Scripts.DynamicAsteroids.AsteroidNetworkMessageContainer">
<Position X="11.75" Y="4" Width="3.5" />
<TypeIdentifier>
<HashCode>AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAA=</HashCode>
<FileName>Data\Scripts\DynamicAsteroids\AsteroidNetworkMessage.cs</FileName>
Expand All @@ -31,43 +32,57 @@
<Property Name="Messages" />
</ShowAsAssociation>
</Class>
<Class Name="DynamicAsteroids.AsteroidSettings">
<Position X="21.25" Y="1.75" Width="2.75" />
<Class Name="DynamicAsteroids.Data.Scripts.DynamicAsteroids.AsteroidZone">
<Position X="9.75" Y="2.75" Width="1.5" />
<TypeIdentifier>
<HashCode>DGBCgIMGAIAIAIBmEkEADBWQOtQJQADGlCQ0ACjUAAA=</HashCode>
<FileName>Data\Scripts\DynamicAsteroids\AsteroidSettings.cs</FileName>
<HashCode>AAAIAAAAAAAAAAAAAAAAAAAAABAgAAAAAAAAAAAIAAA=</HashCode>
<FileName>Data\Scripts\DynamicAsteroids\AsteroidSpawner.cs</FileName>
</TypeIdentifier>
</Class>
<Class Name="DynamicAsteroids.SpawnableArea">
<Position X="1.25" Y="0.75" Width="1.5" />
<Class Name="DynamicAsteroids.Data.Scripts.DynamicAsteroids.AsteroidSpawner">
<Position X="15.5" Y="0.5" Width="2.25" />
<NestedTypes>
<Class Name="DynamicAsteroids.Data.Scripts.DynamicAsteroids.AsteroidSpawner.PlayerMovementData" Collapsed="true">
<TypeIdentifier>
<NewMemberFileName>Data\Scripts\DynamicAsteroids\AsteroidSpawner.cs</NewMemberFileName>
</TypeIdentifier>
</Class>
</NestedTypes>
<TypeIdentifier>
<HashCode>AAAIAAACAAAAAAAAABAAAAQAAAAAAAAAAAAAAAAAABA=</HashCode>
<FileName>Data\Scripts\DynamicAsteroids\AsteroidSettings.cs</FileName>
<HashCode>AQAAAIAAAAAEAEgiqgABgAMQQgAACAAEAgASBgCAIgA=</HashCode>
<FileName>Data\Scripts\DynamicAsteroids\AsteroidSpawner.cs</FileName>
</TypeIdentifier>
</Class>
<Class Name="DynamicAsteroids.MainSession">
<Position X="1" Y="6.5" Width="2" />
<Class Name="DynamicAsteroids.Data.Scripts.DynamicAsteroids.Log">
<Position X="1" Y="0.5" Width="1.5" />
<TypeIdentifier>
<HashCode>AAAAAAAAAAAAAAAAAAAAABAAAAAAAEAAAABCEGCAAIA=</HashCode>
<FileName>Data\Scripts\DynamicAsteroids\Log.cs</FileName>
</TypeIdentifier>
</Class>
<Class Name="DynamicAsteroids.Data.Scripts.DynamicAsteroids.MainSession">
<Position X="9.5" Y="5.25" Width="2" />
<TypeIdentifier>
<HashCode>gAAAAAAAAAAQQAAAgAAAAgICAAQAgIKACAgAACAAAgA=</HashCode>
<FileName>Data\Scripts\DynamicAsteroids\MainSession.cs</FileName>
</TypeIdentifier>
</Class>
<Class Name="Invalid.DynamicRoids.Log">
<Position X="26.25" Y="3.25" Width="1.5" />
<Class Name="AsteroidState">
<Position X="12.75" Y="0.5" Width="1.5" />
<TypeIdentifier>
<HashCode>AAAAAAAAAAAAAAAAAAAAABAAAAAAAEAAAABCEGCAAIA=</HashCode>
<FileName>Data\Scripts\DynamicAsteroids\Log.cs</FileName>
<HashCode>AAAAAAAAAAIAgAAgAAAAAAAAAAAAAAAAAQAAAAAAAAA=</HashCode>
<FileName>Data\Scripts\DynamicAsteroids\AsteroidState.cs</FileName>
</TypeIdentifier>
</Class>
<Struct Name="DynamicAsteroids.AsteroidNetworkMessage">
<Position X="16" Y="3" Width="2" />
<Struct Name="DynamicAsteroids.Data.Scripts.DynamicAsteroids.AsteroidNetworkMessage">
<Position X="0.5" Y="4" Width="2" />
<TypeIdentifier>
<HashCode>AAAAAAAQ5KKDgAAAAAAAwAIAAAAAAEGAAQAAAABAEwA=</HashCode>
<FileName>Data\Scripts\DynamicAsteroids\AsteroidNetworkMessage.cs</FileName>
</TypeIdentifier>
</Struct>
<Enum Name="DynamicAsteroids.AsteroidEntities.AsteroidType">
<Position X="11.5" Y="8.25" Width="1.5" />
<Enum Name="DynamicAsteroids.Data.Scripts.DynamicAsteroids.AsteroidEntities.AsteroidType">
<Position X="12.75" Y="5.5" Width="1.5" />
<TypeIdentifier>
<HashCode>IAgIAAAAAAAAAAAQAACAAAAAAAAAAAgAEAAgAAAAQAE=</HashCode>
<FileName>Data\Scripts\DynamicAsteroids\AsteroidEntities\AsteroidEntity.cs</FileName>
Expand Down
Binary file removed Dynamic Asteroids/DynamicAsteroidsClassDiagram.png
Binary file not shown.

0 comments on commit f799708

Please sign in to comment.