Skip to content

Commit

Permalink
add "warning"
Browse files Browse the repository at this point in the history
  • Loading branch information
Govorunb committed Apr 17, 2024
1 parent f5dd54c commit fd13c70
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 15 deletions.
3 changes: 2 additions & 1 deletion SCHIZO/Events/ErmfishDefenseForce/EdfConsoleCommands.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System.Collections.Generic;
using Nautilus.Commands;
using SCHIZO.ConsoleCommands;
using SCHIZO.Helpers;

namespace SCHIZO.Events.ErmfishDefenseForce;

Expand Down Expand Up @@ -33,7 +34,7 @@ public static string Aggro(IReadOnlyList<string> args)

ErmfishDefenseForce.instance.SetAggro(value, $"{CommandName} aggro");
}
return ErmfishDefenseForce.instance.CurrentAggro.ToString();
return MessageHelpers.GetCommandOutput(ErmfishDefenseForce.instance.CurrentAggro.ToString());

syntax: return $"Syntax: {CommandName} aggro [value]";
}
Expand Down
17 changes: 10 additions & 7 deletions SCHIZO/Events/ErmfishDefenseForce/ErmfishDefenseForce.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,18 +36,18 @@ public IEnumerator GetPrefab(IOut<GameObject> prefab)
}
}

public override bool IsOccurring => _spawning || ActiveDefenders.Count > 0;
public override bool IsOccurring => _spawning;

private bool _spawning;
private float _cooldownTimer;
public bool debugKarma = true;
public bool debugKarma = false;

private void Start()
{
instance = this;

ActiveDefenders = [];
// _cooldownTimer = startCooldown / 2f;
_cooldownTimer = startCooldown / 2f;
}

public void OnCook(TechType techType) => OnAggroEvent(techType, cookAggro);
Expand Down Expand Up @@ -87,9 +87,12 @@ internal void Reset()

protected override bool ShouldStartEvent()
{
return Player.main && !Player.main.currentSub && Player.main.currentInterior is null // don't spawn indoors
return !_spawning
&& CurrentAggro > startAggroThreshold
&& _cooldownTimer <= Time.time;
&& _cooldownTimer <= Time.time
&& Player.main && !Player.main.currentSub && Player.main.currentInterior is null // don't spawn indoors

Check failure on line 93 in SCHIZO/Events/ErmfishDefenseForce/ErmfishDefenseForce.cs

View workflow job for this annotation

GitHub Actions / build (Subnautica)

'Player' does not contain a definition for 'currentInterior' and no accessible extension method 'currentInterior' accepting a first argument of type 'Player' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 93 in SCHIZO/Events/ErmfishDefenseForce/ErmfishDefenseForce.cs

View workflow job for this annotation

GitHub Actions / build (Subnautica)

'Player' does not contain a definition for 'currentInterior' and no accessible extension method 'currentInterior' accepting a first argument of type 'Player' could be found (are you missing a using directive or an assembly reference?)
&& Player.main.IsUnderwaterForSwimming() // there are no land kill squads... yet
;
}

protected override void UpdateLogic()
Expand Down Expand Up @@ -150,7 +153,7 @@ private IEnumerator SpawnDefenderGroup(Defender defender)
}
if (defender.maxGroupSize == 0)
{
ErrorMessage.AddMessage($"delopver forgor to set group size on {defender.ClassId} everybody point and laugh");
ErrorMessage.AddMessage($"delopver forgor to set group size on {defender.name} everybody point and laugh");
yield break;
}
_spawning = true;
Expand All @@ -159,7 +162,7 @@ private IEnumerator SpawnDefenderGroup(Defender defender)
GameObject prefab = prefabTask.Get();
if (!prefab) yield break;
CurrentAggro -= defender.aggroCost * willSpawn;
LOGGER.LogDebug($"(EDF) spawning {willSpawn} {defender.ClassId}");
LOGGER.LogDebug($"(EDF) spawning {defender.name} ({willSpawn} {defender.ClassId})");
for (int i = 0; i < willSpawn; i++)
{
GameObject instance = GameObject.Instantiate(prefab);
Expand Down
19 changes: 14 additions & 5 deletions Unity/Assets/Mod/Events/Event Manager.prefab
Original file line number Diff line number Diff line change
Expand Up @@ -94,19 +94,28 @@ MonoBehaviour:
killedByDefenderAggro: -1000
ermconScoreAggro: {x: -10, y: 50}
defenders:
- _defender: {fileID: 11400000, guid: 5159b45dc6c3d83449b9eb96602c772c, type: 2}
- name: Kill Squad
_defender: {fileID: 11400000, guid: 5159b45dc6c3d83449b9eb96602c772c, type: 2}
aggroCost: 250
maxGroupSize: 5
spawnWeight: 5
- _defender: {fileID: 11400000, guid: c413dda5acae2794f8122a4d7b04cb53, type: 2}
aggroCost: 20
- name: Peace Negotiations
_defender: {fileID: 11400000, guid: c413dda5acae2794f8122a4d7b04cb53, type: 2}
aggroCost: 50
maxGroupSize: 10
spawnWeight: 2
- _defender: {fileID: 11400000, guid: 87067f32545a0f74b95731190912dcd3, type: 2}
- name: Ineffective At Best
_defender: {fileID: 11400000, guid: 87067f32545a0f74b95731190912dcd3, type: 2}
aggroCost: -100
maxGroupSize: 1
spawnWeight: 2
- _defender: {fileID: 11400000, guid: 6abf367663a723f4fa2a8e0715a05a6c, type: 2}
- name: ???
_defender: {fileID: 11400000, guid: 6abf367663a723f4fa2a8e0715a05a6c, type: 2}
aggroCost: 1500
maxGroupSize: 1
spawnWeight: 0
- name: Warning
_defender: {fileID: 11400000, guid: 880f463bbb4c2374aaa6cf41efdbc505, type: 2}
aggroCost: 100
maxGroupSize: 3
spawnWeight: 2
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
using SCHIZO.Items.Data;
using TriInspector;
using UnityEngine;
using OurCreatureData = SCHIZO.Creatures.Data.CreatureData;

namespace SCHIZO.Events.ErmfishDefenseForce
{
Expand Down Expand Up @@ -33,8 +32,9 @@ public partial class ErmfishDefenseForce : GameEvent
[Serializable]
public partial class Defender
{
public string name;
[SerializeField]
private OurCreatureData _defender;
private ItemData _defender;
public string ClassId => _defender.classId;
[Tooltip("Cost to spawn each of this type of defender")]
public float aggroCost;
Expand Down

0 comments on commit fd13c70

Please sign in to comment.