-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add character collision damage disabler
- Loading branch information
1 parent
bd8d00a
commit f799708
Showing
3 changed files
with
90 additions
and
33 deletions.
There are no files selected for viewing
42 changes: 42 additions & 0 deletions
42
CharacterDamageDisabler/Data/Scripts/CharDamageDisabler/CharacterDamageDisabler.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.