Skip to content

Add Faction friends to Destroyable component #246

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 16, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion Uchu.World/Objects/Components/DestroyableComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ public class DestroyableComponent : Component, ISavableComponent

public int[] Factions { get; set; } = new int[0];

public int[] Friends { get; set; } = new int[0];

public int[] Enemies { get; set; } = new int[0];

public uint DamageAbsorptionPoints { get; set; }
Expand Down Expand Up @@ -240,6 +242,16 @@ protected DestroyableComponent()
.Split(',')
.Select(int.Parse)
.ToArray();

if (faction?.FriendList == default) return;

if (string.IsNullOrWhiteSpace(faction.FriendList)) return;

Friends = faction.FriendList
.Replace(" ", "")
.Split(',')
.Select(int.Parse)
.ToArray();
});

Listen(OnDestroyed, () =>
Expand Down Expand Up @@ -442,4 +454,4 @@ public async Task SaveAsync(UchuContext context)
Logger.Debug($"Saved character stats for {GameObject}");
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ public GameObject[] SeekValidTargets()
if (entry.GameObject.TryGetComponent<TriggerComponent>(out _))
continue;

if (Stats.Enemies.Contains(entry.Factions.First()))
if (Stats.Enemies.Contains(entry.Factions.First()) && !Stats.Friends.Contains(entry.Factions.First()))
{
targets.Add(entry.GameObject);
}
Expand Down