Skip to content

Commit b56c6e9

Browse files
committed
fix: Location Based Actions
1 parent 29efe2f commit b56c6e9

1 file changed

Lines changed: 13 additions & 4 deletions

File tree

S1API/Entities/Schedule/ActionSpecs/LocationBasedActionSpec.cs

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -211,8 +211,6 @@ private static bool ToggleBehaviourByName(NPCSchedule schedule, string behaviour
211211
}
212212
else
213213
{
214-
if (index >= 0)
215-
npcBehaviour.DeactivateBehaviour_Server(index);
216214
behaviour.Disable_Networked(null);
217215
}
218216

@@ -271,6 +269,12 @@ private static void ToggleGraffiti(LocationBasedActionSpec spec, NPCSchedule sch
271269
return;
272270
}
273271

272+
if (surface.NetworkObject == null)
273+
{
274+
Logger.Warning("[LocationBasedActionSpec] Graffiti: Spray surface has no NetworkObject, cannot assign behaviour.");
275+
return;
276+
}
277+
274278
var baseNpc = schedule.NPC.S1NPC;
275279
var npcBehaviour = baseNpc.GetComponentInChildren<S1NPCsBehaviour.NPCBehaviour>(true);
276280
var behaviour = npcBehaviour?.GetBehaviour("GraffitiBehaviour");
@@ -281,8 +285,13 @@ private static void ToggleGraffiti(LocationBasedActionSpec spec, NPCSchedule sch
281285
}
282286

283287
var graffitiBehaviour = behaviour as S1NPCsBehaviour.GraffitiBehaviour;
284-
if (graffitiBehaviour != null && surface.NetworkObject != null)
285-
graffitiBehaviour.SetSpraySurface_Client(null, surface.NetworkObject);
288+
if (graffitiBehaviour == null)
289+
{
290+
Logger.Warning("[LocationBasedActionSpec] Graffiti: GraffitiBehaviour could not be cast to the concrete type.");
291+
return;
292+
}
293+
294+
graffitiBehaviour.SetSpraySurface_Client(null, surface.NetworkObject);
286295

287296
ToggleBehaviourByName(schedule, "GraffitiBehaviour", true);
288297
}

0 commit comments

Comments
 (0)