Skip to content

Commit

Permalink
Fix toggle damage (#44)
Browse files Browse the repository at this point in the history
  • Loading branch information
Kexanone authored Jul 6, 2024
1 parent 1cc1d5a commit 77a128a
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 78 deletions.
4 changes: 2 additions & 2 deletions addons/GME/Configs/Editor/AttributeLists/Edit.conf
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
SCR_EditorAttributeList : "{F3D6C6D25642352C}Configs/Editor/AttributeLists/Edit.conf" {
SCR_EditorAttributeList {
m_aAttributes {
GME_ToggleDamageEditorAttribute "{5964E09573BF5AE9}" {
GME_ToggleDamageCharacterAttribute "{5964E09573BF5AE9}" {
m_UIInfo SCR_EditorAttributeUIInfo "{5964E095742FEEF3}" {
Name "#GME-Editor_Attribute_EnableDamage_Name"
m_cDescriptionIconColor 0.947 0.056 0.056 1
Expand Down
2 changes: 2 additions & 0 deletions addons/GME/Configs/Editor/AttributeLists/Edit.conf.meta
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,7 @@ MetaFileClass {
}
CONFResourceClass HEADLESS : PC {
}
CONFResourceClass PS5 : PC {
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
//------------------------------------------------------------------------------------------------
//! Entity attribute for toggle damage on unit
[BaseContainerProps(), SCR_BaseEditorAttributeCustomTitle()]
class GME_ToggleDamageCharacterAttribute : GME_ToggleDamageEditorAttribute
{
//------------------------------------------------------------------------------------------------
override SCR_BaseEditorAttributeVar ReadVariable(Managed item, SCR_AttributesManagerEditorComponent manager)
{
if (!SCR_EditableCharacterComponent.Cast(item))
return null;

return super.ReadVariable(item, manager);
}
}
Original file line number Diff line number Diff line change
@@ -1,29 +1,27 @@
/**
Entity Attribute for toggle damage on unit
*/
//------------------------------------------------------------------------------------------------
//! Entity Attribute for toggle damage on unit
[BaseContainerProps(), SCR_BaseEditorAttributeCustomTitle()]
class GME_ToggleDamageEditorAttribute : SCR_BaseEditorAttribute
{
//------------------------------------------------------------------------------------------------
override SCR_BaseEditorAttributeVar ReadVariable(Managed item, SCR_AttributesManagerEditorComponent manager)
{

SCR_EditableEntityComponent editableEntity = SCR_EditableEntityComponent.Cast(item);
if (!editableEntity)
return null;

IEntity owner = editableEntity.GetOwner();
IEntity owner = editableEntity.GetOwner();
if (!owner)
return null;

if (!SCR_ChimeraCharacter.Cast(owner))
return null;

SCR_DamageManagerComponent damageComponent = SCR_DamageManagerComponent.Cast(owner.FindComponent(SCR_DamageManagerComponent));
if (!damageComponent)
return null;

return SCR_BaseEditorAttributeVar.CreateBool(damageComponent.GME_IsDamageEnabled());
return SCR_BaseEditorAttributeVar.CreateBool(damageComponent.IsDamageHandlingEnabled());
}

//------------------------------------------------------------------------------------------------
override void WriteVariable(Managed item, SCR_BaseEditorAttributeVar var, SCR_AttributesManagerEditorComponent manager, int playerID)
{
if (!var)
Expand All @@ -40,6 +38,6 @@ class GME_ToggleDamageEditorAttribute : SCR_BaseEditorAttribute
if (!damageComponent)
return;

damageComponent.GME_SetDamageEnabled(var.GetBool());;
damageComponent.EnableDamageHandling(var.GetBool());
}
};
}
Original file line number Diff line number Diff line change
@@ -1,46 +1,14 @@
/**
Entity Attribute for toggle damage on unit
*/
//------------------------------------------------------------------------------------------------
//! Entity attribute for toggle damage on vehicle
[BaseContainerProps(), SCR_BaseEditorAttributeCustomTitle()]
class GME_ToggleDamageVehicleEditorAttribute : SCR_BaseEditorAttribute
class GME_ToggleDamageVehicleEditorAttribute : GME_ToggleDamageEditorAttribute
{
//------------------------------------------------------------------------------------------------
override SCR_BaseEditorAttributeVar ReadVariable(Managed item, SCR_AttributesManagerEditorComponent manager)
{

SCR_EditableEntityComponent editableEntity = SCR_EditableEntityComponent.Cast(item);
if (!editableEntity)
return null;

IEntity owner = editableEntity.GetOwner();
if (!owner)
if (!SCR_EditableVehicleComponent.Cast(item))
return null;

if (!Vehicle.Cast(owner))
return null;

DamageManagerComponent damageComponent = DamageManagerComponent.Cast(owner.FindComponent(DamageManagerComponent));

if (!damageComponent)
return null;

return SCR_BaseEditorAttributeVar.CreateBool(damageComponent.IsDamageHandlingEnabled());
}
override void WriteVariable(Managed item, SCR_BaseEditorAttributeVar var, SCR_AttributesManagerEditorComponent manager, int playerID)
{
if (!var)
return;

SCR_EditableEntityComponent editableEntity = SCR_EditableEntityComponent.Cast(item);

IEntity owner = editableEntity.GetOwner();
if (!owner)
return;

DamageManagerComponent damageComponent = DamageManagerComponent.Cast(owner.FindComponent(DamageManagerComponent));
if (!damageComponent)
return;

// toggle damage handling
damageComponent.EnableDamageHandling(var.GetBool());
return super.ReadVariable(item, manager);
}
};
}

This file was deleted.

0 comments on commit 77a128a

Please sign in to comment.