Skip to content

Commit

Permalink
Fix inconsistent usage of "recursively" option for visibility flags (#56
Browse files Browse the repository at this point in the history
)

* Refactor visibility code

* Set recursively to false for SetFlag

* Reformat visibility
  • Loading branch information
Kexanone authored Oct 29, 2024
1 parent 9a48e83 commit 7d1e2ee
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 24 deletions.
11 changes: 5 additions & 6 deletions addons/GME/Scripts/Game/GME/Helpers/GME_VisibilityHelper.c
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
/**
Helper class with staic functions to enable and disable visiblity of units
*/

//------------------------------------------------------------------------------------------------
//! Helper class with staic functions to enable and disable visiblity of units
class GME_VisibilityHelper
{
//------------------------------------------------------------------------------------------------
static void SetVisibility(GenericEntity entity, bool visible)
{
// casting to possible supported types, if not null we found our match and change visibility and return
Expand All @@ -22,9 +21,9 @@ class GME_VisibilityHelper
}
}

//------------------------------------------------------------------------------------------------
static bool GetVisibility(IEntity entity)
{
int visible = entity.GetFlags() & EntityFlags.VISIBLE;
return visible;
return entity.GetFlags() & EntityFlags.VISIBLE;
}
}
20 changes: 10 additions & 10 deletions addons/GME/Scripts/GameCode/GME/Character/SCR_ChimeraCharacter.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,19 +29,19 @@ modded class SCR_ChimeraCharacter : ChimeraCharacter
}

//------------------------------------------------------------------------------------------------
void GME_OnVisibilityValueUpdated()
void GME_SetVisibility(bool visible)
{
if (m_bGME_isVisible)
this.SetFlags(EntityFlags.VISIBLE|EntityFlags.TRACEABLE, m_bGME_isVisible);
else
this.ClearFlags(EntityFlags.VISIBLE|EntityFlags.TRACEABLE);
m_bGME_isVisible = visible;
Replication.BumpMe();
GME_OnVisibilityValueUpdated();
}

//------------------------------------------------------------------------------------------------
void GME_SetVisibility(bool visible)
{
m_bGME_isVisible = visible;
Replication.BumpMe();
this.GME_OnVisibilityValueUpdated();
protected void GME_OnVisibilityValueUpdated()
{
if (m_bGME_isVisible)
SetFlags(EntityFlags.VISIBLE | EntityFlags.TRACEABLE);
else
ClearFlags(EntityFlags.VISIBLE | EntityFlags.TRACEABLE);
}
}
15 changes: 7 additions & 8 deletions addons/GME/Scripts/GameCode/GME/Vehicle/Vehicle.c
Original file line number Diff line number Diff line change
@@ -1,24 +1,23 @@


//------------------------------------------------------------------------------------------------
modded class Vehicle : BaseVehicle
{
[RplProp(onRplName: "GME_OnVisibilityValueUpdated")]
protected bool m_bGME_isVisible = true;

//------------------------------------------------------------------------------------------------
void GME_SetVisibility(bool visible)
{
{
m_bGME_isVisible = visible;
Replication.BumpMe();
this.GME_OnVisibilityValueUpdated();
GME_OnVisibilityValueUpdated();
}


void GME_OnVisibilityValueUpdated()
//------------------------------------------------------------------------------------------------
protected void GME_OnVisibilityValueUpdated()
{
if (m_bGME_isVisible)
this.SetFlags(EntityFlags.VISIBLE|EntityFlags.TRACEABLE, m_bGME_isVisible);
SetFlags(EntityFlags.VISIBLE | EntityFlags.TRACEABLE);
else
this.ClearFlags(EntityFlags.VISIBLE|EntityFlags.TRACEABLE);
ClearFlags(EntityFlags.VISIBLE | EntityFlags.TRACEABLE);
}
};

0 comments on commit 7d1e2ee

Please sign in to comment.