Skip to content

Commit

Permalink
remove unused part field from SmaterButton
Browse files Browse the repository at this point in the history
  • Loading branch information
JonnyOThan committed Aug 14, 2024
1 parent 742e0f1 commit 6139c6f
Showing 1 changed file with 11 additions and 18 deletions.
29 changes: 11 additions & 18 deletions RasterPropMonitor/Core/ButtonHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ public class SmarterButton : MonoBehaviour
private readonly List<Action> clickHandlers = new List<Action>();
private readonly List<Action> releaseHandlers = new List<Action>();
private readonly List<PageTriggerSet> pageTriggers = new List<PageTriggerSet>();
private Part part;

private struct HandlerID
{
Expand Down Expand Up @@ -81,24 +80,21 @@ public void ShowNext()

public void OnMouseDown()
{
if (part != null)
Kerbal k = CameraManager.Instance.ivaCameraActiveKerbal;
if (k != null)
{
Kerbal k = CameraManager.Instance.ivaCameraActiveKerbal;
if (k != null)
// Disallow tourists using props
if (k.protoCrewMember.type == ProtoCrewMember.KerbalType.Tourist)
{
// Disallow tourists using props
if (k.protoCrewMember.type == ProtoCrewMember.KerbalType.Tourist)
if (UnityEngine.Random.Range(0, 10) > 8)
{
if (UnityEngine.Random.Range(0, 10) > 8)
{
ScreenMessages.PostScreenMessage(string.Format("Stop touching buttons, {0}!", k.name), 4.0f, ScreenMessageStyle.UPPER_CENTER);
}
else
{
ScreenMessages.PostScreenMessage(string.Format("Tourist {0} may not operate equipment.", k.name), 4.0f, ScreenMessageStyle.UPPER_CENTER);
}
return;
ScreenMessages.PostScreenMessage(string.Format("Stop touching buttons, {0}!", k.name), 4.0f, ScreenMessageStyle.UPPER_CENTER);
}
else
{
ScreenMessages.PostScreenMessage(string.Format("Tourist {0} may not operate equipment.", k.name), 4.0f, ScreenMessageStyle.UPPER_CENTER);
}
return;
}
}
foreach (PageTriggerSet monitor in pageTriggers)
Expand Down Expand Up @@ -194,7 +190,6 @@ public static void CreateButton(InternalProp thatProp, string buttonName, Monito
}

buttonBehaviour.pageTriggers.Add(new PageTriggerSet(handlerFunction, thatPage));
buttonBehaviour.part = (thatModel == null) ? thatProp.part : thatModel.part;
}

public static void CreateButton(InternalProp thatProp, string buttonName, int numericID, Action<int> clickHandlerFunction, Action<int> releaseHandlerFunction, InternalModel thatModel = null)
Expand All @@ -215,7 +210,6 @@ public static void CreateButton(InternalProp thatProp, string buttonName, int nu
function = releaseHandlerFunction,
idValue = numericID
});
buttonBehaviour.part = (thatModel == null) ? thatProp.part : thatModel.part;
}

public static void CreateButton(InternalProp thatProp, string buttonName, Action handlerFunction, Action releaseHandlerFunction = null, InternalModel thatModel = null)
Expand All @@ -231,7 +225,6 @@ public static void CreateButton(InternalProp thatProp, string buttonName, Action
{
buttonBehaviour.releaseHandlers.Add(releaseHandlerFunction);
}
buttonBehaviour.part = (thatModel == null) ? thatProp.part : thatModel.part;
}
}
}

0 comments on commit 6139c6f

Please sign in to comment.