mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-06-13 00:05:55 +00:00
Map Triggers
This commit is contained in:
parent
5ce2ffb48e
commit
054c0998ad
34 changed files with 5896 additions and 477 deletions
|
|
@ -0,0 +1,8 @@
|
|||
using Godot;
|
||||
using System;
|
||||
|
||||
[Tool]
|
||||
public partial class ActivableSetter : Node
|
||||
{
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1 @@
|
|||
uid://cp8hoxa8tqes3
|
||||
105
3D/TrenchBroom/EntityScripts/Triggers/TriggerArea.cs
Normal file
105
3D/TrenchBroom/EntityScripts/Triggers/TriggerArea.cs
Normal file
|
|
@ -0,0 +1,105 @@
|
|||
using Godot;
|
||||
using System;
|
||||
using Cirno.Scripts;
|
||||
using Cirno.Scripts.Components.FSM._3DPlayer;
|
||||
using Godot.Collections;
|
||||
|
||||
[Tool]
|
||||
public partial class TriggerArea : Area3D
|
||||
{
|
||||
[Export] public string Target { get; private set; }
|
||||
[Export] public string TargetFunc { get; private set; }
|
||||
[Export] public string TargetName { get; private set; }
|
||||
|
||||
public enum TriggerStates
|
||||
{
|
||||
READY,
|
||||
USED
|
||||
}
|
||||
|
||||
private TriggerStates _triggerState = TriggerStates.READY;
|
||||
|
||||
private float _timeout = 0f;
|
||||
private Node _lastActivator;
|
||||
|
||||
public void _func_godot_apply_properties(Dictionary<string, string> props)
|
||||
{
|
||||
Target = props["target"];
|
||||
TargetFunc = props["targetfunc"];
|
||||
TargetName = props["targetname"];
|
||||
}
|
||||
|
||||
public void _on_ent_entered(Node ent)
|
||||
{
|
||||
GD.Print($"Trigger entered by {ent.Name}");
|
||||
if (_triggerState is TriggerStates.READY)
|
||||
{
|
||||
if (ent is IsoPlayerFSMProxy)
|
||||
{
|
||||
GD.Print($"Entity {ent} is player, trying to use");
|
||||
Use();
|
||||
}
|
||||
else
|
||||
{
|
||||
GD.Print($"{ent.Name} was not interaction controller");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
GD.Print("Trigger was not ready");
|
||||
}
|
||||
}
|
||||
|
||||
public void Use()
|
||||
{
|
||||
if (_triggerState is TriggerStates.READY)
|
||||
{
|
||||
_triggerState = TriggerStates.USED;
|
||||
ToggleCollision(false);
|
||||
|
||||
UseTargets(this, Target);
|
||||
}
|
||||
}
|
||||
|
||||
private void UseTargets(Node activator, string target)
|
||||
{
|
||||
GD.Print($"Trying to use targets called: {target}");
|
||||
var targetList = GetTree().GetNodesInGroup(target);
|
||||
foreach (var t in targetList)
|
||||
{
|
||||
//string f;
|
||||
GD.Print($"Trying to use {t.Name}");
|
||||
if (t is IActivable activable)
|
||||
{
|
||||
GD.Print($"Activating {t.Name}");
|
||||
activable.Toggle();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void ToggleCollision(bool toggle)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// Called when the node enters the scene tree for the first time.
|
||||
public override void _Ready()
|
||||
{
|
||||
if (Engine.IsEditorHint()) return;
|
||||
|
||||
//TBGAME.set_targetname(self, targetname)
|
||||
if (!string.IsNullOrEmpty(TargetName))
|
||||
{
|
||||
this.AddToGroup(TargetName);
|
||||
}
|
||||
}
|
||||
|
||||
public TriggerArea()
|
||||
{
|
||||
Monitoring = true;
|
||||
Monitorable = false;
|
||||
BodyEntered += _on_ent_entered;
|
||||
//AreaEntered += _on_ent_entered;
|
||||
}
|
||||
|
||||
}
|
||||
1
3D/TrenchBroom/EntityScripts/Triggers/TriggerArea.cs.uid
Normal file
1
3D/TrenchBroom/EntityScripts/Triggers/TriggerArea.cs.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://bafphlee7g81i
|
||||
Loading…
Add table
Add a link
Reference in a new issue