This commit is contained in:
2026-07-09 21:33:33 +02:00
commit 84a2a365f3
2364 changed files with 950134 additions and 0 deletions
@@ -0,0 +1,44 @@
using System;
using Sirenix.OdinInspector;
using UnityEngine;
using VOID.Generic.Dict;
using VOID.ScriptableObjects.Affiliation;
namespace VOID.Generic.Objects.Unit
{
[Serializable]
public class UnitObjectAttitude : ObjectComponent<UnitObject>
{
[Required]
[SerializeField]
public Faction faction;
public AttitudeType GetAttitudeWith(UnitObject targetUnit)
{
var targetFaction = targetUnit.unitAttitude.faction;
if (!faction || !targetFaction)
{
Debug.LogWarning($"This unit ({parent.name}) and/or another unit ({targetUnit.name}) has no faction selected! Using neutral!", parent);
return AttitudeType.Neutral;
}
var targetAttitude = targetFaction.GetAttitudeFor(faction);
var thisAttitude = faction.GetAttitudeFor(targetFaction);
// Both have attitudes toward themselves - get worse one
if (thisAttitude.HasValue && targetAttitude.HasValue)
return thisAttitude.Value > targetAttitude.Value ? targetAttitude.Value : thisAttitude.Value;
// Only this unit have attitude towards target unit
if (thisAttitude.HasValue)
return thisAttitude.Value;
// Only target unit have attitude towards this unit
if (targetAttitude.HasValue)
return targetAttitude.Value;
return AttitudeType.Neutral;
}
}
}