mirror of
https://github.com/tribufu/ServerManagers
synced 2026-05-06 15:17:34 +00:00
source code checkin
This commit is contained in:
parent
5f8fb2c825
commit
7e57b72e35
675 changed files with 168433 additions and 0 deletions
132
src/ARKServerManager/Lib/ViewModel/DinoSettings.cs
Normal file
132
src/ARKServerManager/Lib/ViewModel/DinoSettings.cs
Normal file
|
|
@ -0,0 +1,132 @@
|
|||
using ServerManagerTool.Enums;
|
||||
using System;
|
||||
using System.Windows;
|
||||
|
||||
namespace ServerManagerTool.Lib.ViewModel
|
||||
{
|
||||
//
|
||||
// This class aggregates many settings related to dinos
|
||||
//
|
||||
public class DinoSettings : DependencyObject
|
||||
{
|
||||
public static readonly DependencyProperty ClassNameProperty = DependencyProperty.Register(nameof(ClassName), typeof(string), typeof(DinoSettings), new PropertyMetadata(String.Empty));
|
||||
public static readonly DependencyProperty ModProperty = DependencyProperty.Register(nameof(Mod), typeof(string), typeof(DinoSettings), new PropertyMetadata(String.Empty));
|
||||
public static readonly DependencyProperty KnownDinoProperty = DependencyProperty.Register(nameof(KnownDino), typeof(bool), typeof(DinoSettings), new PropertyMetadata(false));
|
||||
public static readonly DependencyProperty CanTameProperty = DependencyProperty.Register(nameof(CanTame), typeof(bool), typeof(DinoSettings), new PropertyMetadata(true));
|
||||
public static readonly DependencyProperty CanSpawnProperty = DependencyProperty.Register(nameof(CanSpawn), typeof(bool), typeof(DinoSettings), new PropertyMetadata(true));
|
||||
public static readonly DependencyProperty ReplacementClassProperty = DependencyProperty.Register(nameof(ReplacementClass), typeof(string), typeof(DinoSettings), new PropertyMetadata(String.Empty));
|
||||
public static readonly DependencyProperty SpawnWeightMultiplierProperty = DependencyProperty.Register(nameof(SpawnWeightMultiplier), typeof(float), typeof(DinoSettings), new PropertyMetadata(DinoSpawn.DEFAULT_SPAWN_WEIGHT_MULTIPLIER));
|
||||
public static readonly DependencyProperty OverrideSpawnLimitPercentageProperty = DependencyProperty.Register(nameof(OverrideSpawnLimitPercentage), typeof(bool), typeof(DinoSettings), new PropertyMetadata(DinoSpawn.DEFAULT_OVERRIDE_SPAWN_LIMIT_PERCENTAGE));
|
||||
public static readonly DependencyProperty SpawnLimitPercentageProperty = DependencyProperty.Register(nameof(SpawnLimitPercentage), typeof(float), typeof(DinoSettings), new PropertyMetadata(DinoSpawn.DEFAULT_SPAWN_LIMIT_PERCENTAGE));
|
||||
public static readonly DependencyProperty TamedDamageMultiplierProperty = DependencyProperty.Register(nameof(TamedDamageMultiplier), typeof(float), typeof(DinoSettings), new PropertyMetadata(ClassMultiplier.DEFAULT_MULTIPLIER));
|
||||
public static readonly DependencyProperty TamedResistanceMultiplierProperty = DependencyProperty.Register(nameof(TamedResistanceMultiplier), typeof(float), typeof(DinoSettings), new PropertyMetadata(ClassMultiplier.DEFAULT_MULTIPLIER));
|
||||
public static readonly DependencyProperty WildDamageMultiplierProperty = DependencyProperty.Register(nameof(WildDamageMultiplier), typeof(float), typeof(DinoSettings), new PropertyMetadata(ClassMultiplier.DEFAULT_MULTIPLIER));
|
||||
public static readonly DependencyProperty WildResistanceMultiplierProperty = DependencyProperty.Register(nameof(WildResistanceMultiplier), typeof(float), typeof(DinoSettings), new PropertyMetadata(ClassMultiplier.DEFAULT_MULTIPLIER));
|
||||
|
||||
public string ClassName
|
||||
{
|
||||
get { return (string)GetValue(ClassNameProperty); }
|
||||
set { SetValue(ClassNameProperty, value); }
|
||||
}
|
||||
|
||||
public string Mod
|
||||
{
|
||||
get { return (string)GetValue(ModProperty); }
|
||||
set { SetValue(ModProperty, value); }
|
||||
}
|
||||
|
||||
public bool KnownDino
|
||||
{
|
||||
get { return (bool)GetValue(KnownDinoProperty); }
|
||||
set { SetValue(KnownDinoProperty, value); }
|
||||
}
|
||||
|
||||
public bool CanTame
|
||||
{
|
||||
get { return (bool)GetValue(CanTameProperty); }
|
||||
set { SetValue(CanTameProperty, value); }
|
||||
}
|
||||
|
||||
public bool CanSpawn
|
||||
{
|
||||
get { return (bool)GetValue(CanSpawnProperty); }
|
||||
set { SetValue(CanSpawnProperty, value); }
|
||||
}
|
||||
|
||||
public string ReplacementClass
|
||||
{
|
||||
get { return (string)GetValue(ReplacementClassProperty); }
|
||||
set { SetValue(ReplacementClassProperty, value); }
|
||||
}
|
||||
|
||||
public float SpawnWeightMultiplier
|
||||
{
|
||||
get { return (float)GetValue(SpawnWeightMultiplierProperty); }
|
||||
set { SetValue(SpawnWeightMultiplierProperty, value); }
|
||||
}
|
||||
|
||||
public bool OverrideSpawnLimitPercentage
|
||||
{
|
||||
get { return (bool)GetValue(OverrideSpawnLimitPercentageProperty); }
|
||||
set { SetValue(OverrideSpawnLimitPercentageProperty, value); }
|
||||
}
|
||||
|
||||
public float SpawnLimitPercentage
|
||||
{
|
||||
get { return (float)GetValue(SpawnLimitPercentageProperty); }
|
||||
set { SetValue(SpawnLimitPercentageProperty, value); }
|
||||
}
|
||||
|
||||
public float TamedDamageMultiplier
|
||||
{
|
||||
get { return (float)GetValue(TamedDamageMultiplierProperty); }
|
||||
set { SetValue(TamedDamageMultiplierProperty, value); }
|
||||
}
|
||||
|
||||
public float TamedResistanceMultiplier
|
||||
{
|
||||
get { return (float)GetValue(TamedResistanceMultiplierProperty); }
|
||||
set { SetValue(TamedResistanceMultiplierProperty, value); }
|
||||
}
|
||||
|
||||
public float WildDamageMultiplier
|
||||
{
|
||||
get { return (float)GetValue(WildDamageMultiplierProperty); }
|
||||
set { SetValue(WildDamageMultiplierProperty, value); }
|
||||
}
|
||||
|
||||
public float WildResistanceMultiplier
|
||||
{
|
||||
get { return (float)GetValue(WildResistanceMultiplierProperty); }
|
||||
set { SetValue(WildResistanceMultiplierProperty, value); }
|
||||
}
|
||||
|
||||
public string DisplayName => GameData.FriendlyCreatureNameForClass(ClassName);
|
||||
public string DisplayMod => GameData.FriendlyNameForClass($"Mod_{Mod}", true) ?? Mod;
|
||||
public string NameTag { get; internal set; }
|
||||
public bool HasNameTag { get; internal set; }
|
||||
public bool HasClassName { get; internal set; }
|
||||
public bool IsSpawnable { get; internal set; }
|
||||
public DinoTamable IsTameable { get; internal set; }
|
||||
public string DisplayReplacementName => GameData.FriendlyCreatureNameForClass(ReplacementClass);
|
||||
|
||||
public float OriginalSpawnWeightMultiplier { get; internal set; }
|
||||
public bool OriginalOverrideSpawnLimitPercentage { get; internal set; }
|
||||
public float OriginalSpawnLimitPercentage { get; internal set; }
|
||||
|
||||
#region Sort Properties
|
||||
public string NameSort => $"{DisplayName}|{Mod}";
|
||||
public string ModSort => $"{Mod}|{DisplayName}";
|
||||
public string CanSpawnSort => $"{IsSpawnable}|{CanSpawn}|{DisplayName}|{Mod}";
|
||||
public string CanTameSort => $"{IsTameable != DinoTamable.False}|{CanTame}|{DisplayName}|{Mod}";
|
||||
public string ReplacementNameSort => $"{DisplayReplacementName}|{Mod}";
|
||||
public string SpawnWeightMultiplierSort => $"{SpawnWeightMultiplier:0000000000.0000000000}|{DisplayName}|{Mod}";
|
||||
public string OverrideSpawnLimitPercentageSort => $"{OverrideSpawnLimitPercentage}|{DisplayName}|{Mod}";
|
||||
public string SpawnLimitPercentageSort => $"{SpawnLimitPercentage:0000000000.0000000000}|{DisplayName}|{Mod}";
|
||||
public string TamedDamageMultiplierSort => $"{TamedDamageMultiplier:0000000000.0000000000}|{DisplayName}|{Mod}";
|
||||
public string TamedResistanceMultiplierSort => $"{TamedResistanceMultiplier:0000000000.0000000000}|{DisplayName}|{Mod}";
|
||||
public string WildDamageMultiplierSort => $"{WildDamageMultiplier:0000000000.0000000000}|{DisplayName}|{Mod}";
|
||||
public string WildResistanceMultiplierSort => $"{WildResistanceMultiplier:0000000000.0000000000}|{DisplayName}|{Mod}";
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
316
src/ARKServerManager/Lib/ViewModel/DinoSettingsList.cs
Normal file
316
src/ARKServerManager/Lib/ViewModel/DinoSettingsList.cs
Normal file
|
|
@ -0,0 +1,316 @@
|
|||
using ServerManagerTool.Common.Model;
|
||||
using ServerManagerTool.Enums;
|
||||
using System;
|
||||
using System.Linq;
|
||||
|
||||
namespace ServerManagerTool.Lib.ViewModel
|
||||
{
|
||||
public class DinoSettingsList : SortableObservableCollection<DinoSettings>
|
||||
{
|
||||
public AggregateIniValueList<DinoSpawn> DinoSpawnWeightMultipliers { get; }
|
||||
public StringIniValueList PreventDinoTameClassNames { get; }
|
||||
public AggregateIniValueList<NPCReplacement> NpcReplacements { get; }
|
||||
public AggregateIniValueList<ClassMultiplier> TamedDinoClassDamageMultipliers { get; }
|
||||
public AggregateIniValueList<ClassMultiplier> TamedDinoClassResistanceMultipliers { get; }
|
||||
public AggregateIniValueList<ClassMultiplier> DinoClassDamageMultipliers { get; }
|
||||
public AggregateIniValueList<ClassMultiplier> DinoClassResistanceMultipliers { get; }
|
||||
|
||||
public DinoSettingsList()
|
||||
{
|
||||
Reset();
|
||||
}
|
||||
|
||||
public DinoSettingsList(AggregateIniValueList<DinoSpawn> dinoSpawnWeightMultipliers, StringIniValueList preventDinoTameClassNames, AggregateIniValueList<NPCReplacement> npcReplacements,
|
||||
AggregateIniValueList<ClassMultiplier> tamedDinoClassDamageMultipliers, AggregateIniValueList<ClassMultiplier> tamedDinoClassResistanceMultipliers,
|
||||
AggregateIniValueList<ClassMultiplier> dinoClassDamageMultipliers, AggregateIniValueList<ClassMultiplier> dinoClassResistanceMultipliers)
|
||||
{
|
||||
this.DinoSpawnWeightMultipliers = dinoSpawnWeightMultipliers;
|
||||
this.PreventDinoTameClassNames = preventDinoTameClassNames;
|
||||
this.NpcReplacements = npcReplacements;
|
||||
this.TamedDinoClassDamageMultipliers = tamedDinoClassDamageMultipliers;
|
||||
this.TamedDinoClassResistanceMultipliers = tamedDinoClassResistanceMultipliers;
|
||||
this.DinoClassDamageMultipliers = dinoClassDamageMultipliers;
|
||||
this.DinoClassResistanceMultipliers = dinoClassResistanceMultipliers;
|
||||
Reset();
|
||||
}
|
||||
|
||||
private DinoSettings CreateDinoSetting(string className, string mod, bool knownDino, bool hasNameTag, bool hasClassName)
|
||||
{
|
||||
var nameTag = GameData.NameTagForClass(className);
|
||||
var isSpawnable = GameData.IsSpawnableForClass(className);
|
||||
var isTameable = GameData.IsTameableForClass(className);
|
||||
|
||||
return new DinoSettings()
|
||||
{
|
||||
ClassName = className,
|
||||
Mod = mod,
|
||||
KnownDino = knownDino,
|
||||
NameTag = nameTag,
|
||||
|
||||
CanSpawn = true,
|
||||
CanTame = isTameable != DinoTamable.False,
|
||||
ReplacementClass = className,
|
||||
|
||||
SpawnWeightMultiplier = DinoSpawn.DEFAULT_SPAWN_WEIGHT_MULTIPLIER,
|
||||
OverrideSpawnLimitPercentage = DinoSpawn.DEFAULT_OVERRIDE_SPAWN_LIMIT_PERCENTAGE,
|
||||
SpawnLimitPercentage = DinoSpawn.DEFAULT_SPAWN_LIMIT_PERCENTAGE,
|
||||
OriginalSpawnWeightMultiplier = DinoSpawn.DEFAULT_SPAWN_WEIGHT_MULTIPLIER,
|
||||
OriginalOverrideSpawnLimitPercentage = DinoSpawn.DEFAULT_OVERRIDE_SPAWN_LIMIT_PERCENTAGE,
|
||||
OriginalSpawnLimitPercentage = DinoSpawn.DEFAULT_SPAWN_LIMIT_PERCENTAGE,
|
||||
|
||||
TamedDamageMultiplier = ClassMultiplier.DEFAULT_MULTIPLIER,
|
||||
TamedResistanceMultiplier = ClassMultiplier.DEFAULT_MULTIPLIER,
|
||||
WildDamageMultiplier = ClassMultiplier.DEFAULT_MULTIPLIER,
|
||||
WildResistanceMultiplier = ClassMultiplier.DEFAULT_MULTIPLIER,
|
||||
|
||||
HasClassName = hasClassName,
|
||||
HasNameTag = hasNameTag,
|
||||
IsSpawnable = isSpawnable,
|
||||
IsTameable = isTameable,
|
||||
};
|
||||
}
|
||||
|
||||
public void Reset()
|
||||
{
|
||||
this.Clear();
|
||||
|
||||
var dinoSpawns = GameData.GetDinoSpawns();
|
||||
foreach (var entry in dinoSpawns)
|
||||
{
|
||||
this.Add(CreateDinoSetting(entry.ClassName, entry.Mod, entry.KnownDino, entry.DinoNameTag != null, true));
|
||||
}
|
||||
|
||||
Sort(d => d.NameSort);
|
||||
}
|
||||
|
||||
public void RenderToView()
|
||||
{
|
||||
Reset();
|
||||
|
||||
foreach(var entry in this.DinoSpawnWeightMultipliers)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(entry.DinoNameTag))
|
||||
continue;
|
||||
|
||||
var dinoSettings = this.Where(vi => vi.NameTag == entry.DinoNameTag).ToArray();
|
||||
if (dinoSettings == null || dinoSettings.Length == 0)
|
||||
{
|
||||
this.Add(CreateDinoSetting(entry.DinoNameTag, entry.Mod, entry.KnownDino, true, false));
|
||||
}
|
||||
|
||||
dinoSettings = this.Where(vi => vi.NameTag == entry.DinoNameTag).ToArray();
|
||||
foreach (var dinoSetting in dinoSettings)
|
||||
{
|
||||
dinoSetting.SpawnWeightMultiplier = entry.SpawnWeightMultiplier;
|
||||
dinoSetting.OverrideSpawnLimitPercentage = entry.OverrideSpawnLimitPercentage;
|
||||
dinoSetting.SpawnLimitPercentage = entry.SpawnLimitPercentage;
|
||||
|
||||
dinoSetting.OriginalSpawnWeightMultiplier = entry.SpawnWeightMultiplier;
|
||||
dinoSetting.OriginalOverrideSpawnLimitPercentage = entry.OverrideSpawnLimitPercentage;
|
||||
dinoSetting.OriginalSpawnLimitPercentage = entry.SpawnLimitPercentage;
|
||||
}
|
||||
}
|
||||
|
||||
foreach(var entry in this.PreventDinoTameClassNames)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(entry))
|
||||
continue;
|
||||
|
||||
var dinoSettings = this.Where(vi => vi.ClassName == entry).ToArray();
|
||||
if (dinoSettings == null || dinoSettings.Length == 0)
|
||||
{
|
||||
this.Add(CreateDinoSetting(entry, GameData.MOD_UNKNOWN, false, false, true));
|
||||
}
|
||||
|
||||
dinoSettings = this.Where(vi => vi.ClassName == entry).ToArray();
|
||||
foreach (var dinoSetting in dinoSettings)
|
||||
{
|
||||
dinoSetting.CanTame = false;
|
||||
}
|
||||
}
|
||||
|
||||
foreach(var entry in this.NpcReplacements)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(entry.FromClassName))
|
||||
continue;
|
||||
|
||||
var dinoSettings = this.Where(vi => vi.ClassName == entry.FromClassName).ToArray();
|
||||
if (dinoSettings == null || dinoSettings.Length == 0)
|
||||
{
|
||||
this.Add(CreateDinoSetting(entry.FromClassName, GameData.MOD_UNKNOWN, false, false, true));
|
||||
}
|
||||
|
||||
dinoSettings = this.Where(vi => vi.ClassName == entry.FromClassName).ToArray();
|
||||
foreach (var dinoSetting in dinoSettings)
|
||||
{
|
||||
dinoSetting.CanSpawn = !string.IsNullOrWhiteSpace(entry.ToClassName);
|
||||
dinoSetting.ReplacementClass = dinoSetting.CanSpawn ? entry.ToClassName : dinoSetting.ClassName;
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var entry in this.TamedDinoClassDamageMultipliers)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(entry.ClassName))
|
||||
continue;
|
||||
|
||||
var dinoSettings = this.Where(vi => vi.ClassName == entry.ClassName).ToArray();
|
||||
if (dinoSettings == null || dinoSettings.Length == 0)
|
||||
{
|
||||
this.Add(CreateDinoSetting(entry.ClassName, GameData.MOD_UNKNOWN, false, false, true));
|
||||
}
|
||||
|
||||
dinoSettings = this.Where(vi => vi.ClassName == entry.ClassName).ToArray();
|
||||
foreach (var dinoSetting in dinoSettings)
|
||||
{
|
||||
dinoSetting.TamedDamageMultiplier = entry.Multiplier;
|
||||
}
|
||||
}
|
||||
|
||||
foreach(var entry in this.TamedDinoClassResistanceMultipliers)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(entry.ClassName))
|
||||
continue;
|
||||
|
||||
var dinoSettings = this.Where(vi => vi.ClassName == entry.ClassName).ToArray();
|
||||
if (dinoSettings == null || dinoSettings.Length == 0)
|
||||
{
|
||||
this.Add(CreateDinoSetting(entry.ClassName, GameData.MOD_UNKNOWN, false, false, true));
|
||||
}
|
||||
|
||||
dinoSettings = this.Where(vi => vi.ClassName == entry.ClassName).ToArray();
|
||||
foreach (var dinoSetting in dinoSettings)
|
||||
{
|
||||
dinoSetting.TamedResistanceMultiplier = entry.Multiplier;
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var entry in this.DinoClassDamageMultipliers)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(entry.ClassName))
|
||||
continue;
|
||||
|
||||
var dinoSettings = this.Where(vi => vi.ClassName == entry.ClassName).ToArray();
|
||||
if (dinoSettings == null || dinoSettings.Length == 0)
|
||||
{
|
||||
this.Add(CreateDinoSetting(entry.ClassName, GameData.MOD_UNKNOWN, false, false, true));
|
||||
}
|
||||
|
||||
dinoSettings = this.Where(vi => vi.ClassName == entry.ClassName).ToArray();
|
||||
foreach (var dinoSetting in dinoSettings)
|
||||
{
|
||||
dinoSetting.WildDamageMultiplier = entry.Multiplier;
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var entry in this.DinoClassResistanceMultipliers)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(entry.ClassName))
|
||||
continue;
|
||||
|
||||
var dinoSettings = this.Where(vi => vi.ClassName == entry.ClassName).ToArray();
|
||||
if (dinoSettings == null || dinoSettings.Length == 0)
|
||||
{
|
||||
this.Add(CreateDinoSetting(entry.ClassName, GameData.MOD_UNKNOWN, false, false, true));
|
||||
}
|
||||
|
||||
dinoSettings = this.Where(vi => vi.ClassName == entry.ClassName).ToArray();
|
||||
foreach (var dinoSetting in dinoSettings)
|
||||
{
|
||||
dinoSetting.WildResistanceMultiplier = entry.Multiplier;
|
||||
}
|
||||
}
|
||||
|
||||
Sort(d => d.NameSort);
|
||||
}
|
||||
|
||||
public void RenderToModel()
|
||||
{
|
||||
this.DinoSpawnWeightMultipliers.Clear();
|
||||
this.PreventDinoTameClassNames.Clear();
|
||||
this.PreventDinoTameClassNames.IsEnabled = true;
|
||||
this.NpcReplacements.Clear();
|
||||
this.NpcReplacements.IsEnabled = true;
|
||||
this.TamedDinoClassDamageMultipliers.Clear();
|
||||
this.TamedDinoClassResistanceMultipliers.Clear();
|
||||
this.DinoClassDamageMultipliers.Clear();
|
||||
this.DinoClassResistanceMultipliers.Clear();
|
||||
|
||||
foreach(var entry in this)
|
||||
{
|
||||
if (entry.HasNameTag && !string.IsNullOrWhiteSpace(entry.NameTag))
|
||||
{
|
||||
if (!entry.KnownDino ||
|
||||
!entry.OverrideSpawnLimitPercentage.Equals(DinoSpawn.DEFAULT_OVERRIDE_SPAWN_LIMIT_PERCENTAGE) ||
|
||||
!entry.SpawnLimitPercentage.Equals(DinoSpawn.DEFAULT_SPAWN_LIMIT_PERCENTAGE) ||
|
||||
!entry.SpawnWeightMultiplier.Equals(DinoSpawn.DEFAULT_SPAWN_WEIGHT_MULTIPLIER))
|
||||
{
|
||||
|
||||
var dinoSpawns = this.DinoSpawnWeightMultipliers.Where(d => d.DinoNameTag.Equals(entry.NameTag, StringComparison.OrdinalIgnoreCase)).ToArray();
|
||||
if (dinoSpawns == null || dinoSpawns.Length == 0)
|
||||
{
|
||||
this.DinoSpawnWeightMultipliers.Add(new DinoSpawn()
|
||||
{
|
||||
ClassName = entry.ClassName,
|
||||
DinoNameTag = entry.NameTag,
|
||||
OverrideSpawnLimitPercentage = entry.OverrideSpawnLimitPercentage,
|
||||
SpawnLimitPercentage = entry.SpawnLimitPercentage,
|
||||
SpawnWeightMultiplier = entry.SpawnWeightMultiplier
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (var dinoSpawn in dinoSpawns)
|
||||
{
|
||||
if (entry.SpawnWeightMultiplier != entry.OriginalSpawnWeightMultiplier ||
|
||||
entry.OverrideSpawnLimitPercentage != entry.OriginalOverrideSpawnLimitPercentage ||
|
||||
entry.SpawnLimitPercentage != entry.OriginalSpawnLimitPercentage)
|
||||
{
|
||||
dinoSpawn.OverrideSpawnLimitPercentage = entry.OverrideSpawnLimitPercentage;
|
||||
dinoSpawn.SpawnLimitPercentage = entry.SpawnLimitPercentage;
|
||||
dinoSpawn.SpawnWeightMultiplier = entry.SpawnWeightMultiplier;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (entry.HasClassName && !string.IsNullOrWhiteSpace(entry.ClassName))
|
||||
{
|
||||
if ((entry.IsTameable != DinoTamable.False) && !entry.CanTame)
|
||||
{
|
||||
this.PreventDinoTameClassNames.Add(entry.ClassName);
|
||||
}
|
||||
|
||||
this.NpcReplacements.Add(new NPCReplacement() { FromClassName = entry.ClassName, ToClassName = entry.CanSpawn ? entry.ReplacementClass : string.Empty });
|
||||
|
||||
if (entry.IsTameable != DinoTamable.False)
|
||||
{
|
||||
// check if the value has changed.
|
||||
if (!entry.TamedDamageMultiplier.Equals(ClassMultiplier.DEFAULT_MULTIPLIER))
|
||||
this.TamedDinoClassDamageMultipliers.Add(new ClassMultiplier() { ClassName = entry.ClassName, Multiplier = entry.TamedDamageMultiplier });
|
||||
|
||||
// check if the value has changed.
|
||||
if (!entry.TamedResistanceMultiplier.Equals(ClassMultiplier.DEFAULT_MULTIPLIER))
|
||||
this.TamedDinoClassResistanceMultipliers.Add(new ClassMultiplier() { ClassName = entry.ClassName, Multiplier = entry.TamedResistanceMultiplier });
|
||||
}
|
||||
|
||||
// check if the value has changed.
|
||||
if (!entry.WildDamageMultiplier.Equals(ClassMultiplier.DEFAULT_MULTIPLIER))
|
||||
this.DinoClassDamageMultipliers.Add(new ClassMultiplier() { ClassName = entry.ClassName, Multiplier = entry.WildDamageMultiplier });
|
||||
|
||||
// check if the value has changed.
|
||||
if (!entry.WildResistanceMultiplier.Equals(ClassMultiplier.DEFAULT_MULTIPLIER))
|
||||
this.DinoClassResistanceMultipliers.Add(new ClassMultiplier() { ClassName = entry.ClassName, Multiplier = entry.WildResistanceMultiplier });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void UpdateForLocalization()
|
||||
{
|
||||
//foreach (var dinoSetting in this)
|
||||
//{
|
||||
// dinoSetting.FriendlyName = GameData.FriendlyNameForClass(dinoSetting.ClassName);
|
||||
//}
|
||||
}
|
||||
}
|
||||
}
|
||||
74
src/ARKServerManager/Lib/ViewModel/Engram.cs
Normal file
74
src/ARKServerManager/Lib/ViewModel/Engram.cs
Normal file
|
|
@ -0,0 +1,74 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
|
||||
namespace ServerManagerTool.Lib.ViewModel
|
||||
{
|
||||
public class Engram : DependencyObject
|
||||
{
|
||||
public static readonly DependencyProperty EngramClassNameProperty = DependencyProperty.Register(nameof(EngramClassName), typeof(string), typeof(Engram), new PropertyMetadata(String.Empty));
|
||||
public static readonly DependencyProperty EngramLevelRequirementProperty = DependencyProperty.Register(nameof(EngramLevelRequirement), typeof(int), typeof(Engram), new PropertyMetadata(0));
|
||||
public static readonly DependencyProperty EngramPointsCostProperty = DependencyProperty.Register(nameof(EngramPointsCost), typeof(int), typeof(Engram), new PropertyMetadata(0));
|
||||
public static readonly DependencyProperty ModProperty = DependencyProperty.Register(nameof(Mod), typeof(string), typeof(Engram), new PropertyMetadata(String.Empty));
|
||||
public static readonly DependencyProperty KnownEngramProperty = DependencyProperty.Register(nameof(KnownEngram), typeof(bool), typeof(Engram), new PropertyMetadata(false));
|
||||
public static readonly DependencyProperty IsTekgramProperty = DependencyProperty.Register(nameof(IsTekgram), typeof(bool), typeof(EngramEntry), new PropertyMetadata(false));
|
||||
|
||||
public string EngramClassName
|
||||
{
|
||||
get { return (string)GetValue(EngramClassNameProperty); }
|
||||
set { SetValue(EngramClassNameProperty, value); }
|
||||
}
|
||||
|
||||
public int EngramLevelRequirement
|
||||
{
|
||||
get { return (int)GetValue(EngramLevelRequirementProperty); }
|
||||
set { SetValue(EngramLevelRequirementProperty, value); }
|
||||
}
|
||||
|
||||
public int EngramPointsCost
|
||||
{
|
||||
get { return (int)GetValue(EngramPointsCostProperty); }
|
||||
set { SetValue(EngramPointsCostProperty, value); }
|
||||
}
|
||||
|
||||
public string Mod
|
||||
{
|
||||
get { return (string)GetValue(ModProperty); }
|
||||
set { SetValue(ModProperty, value); }
|
||||
}
|
||||
|
||||
public bool KnownEngram
|
||||
{
|
||||
get { return (bool)GetValue(KnownEngramProperty); }
|
||||
set { SetValue(KnownEngramProperty, value); }
|
||||
}
|
||||
|
||||
public bool IsTekgram
|
||||
{
|
||||
get { return (bool)GetValue(IsTekgramProperty); }
|
||||
set { SetValue(IsTekgramProperty, value); }
|
||||
}
|
||||
|
||||
public string DisplayName => GameData.FriendlyEngramNameForClass(EngramClassName);
|
||||
|
||||
public string DisplayMod => GameData.FriendlyNameForClass($"Mod_{Mod}", true) ?? Mod;
|
||||
|
||||
public Engram Duplicate()
|
||||
{
|
||||
var properties = this.GetType().GetProperties();
|
||||
|
||||
var result = new Engram();
|
||||
foreach (var prop in properties)
|
||||
{
|
||||
if (prop.CanWrite)
|
||||
prop.SetValue(result, prop.GetValue(this));
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
362
src/ARKServerManager/Lib/ViewModel/EngramSettings.cs
Normal file
362
src/ARKServerManager/Lib/ViewModel/EngramSettings.cs
Normal file
|
|
@ -0,0 +1,362 @@
|
|||
using ServerManagerTool.Common.Model;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Windows;
|
||||
|
||||
namespace ServerManagerTool.Lib.ViewModel
|
||||
{
|
||||
[DataContract]
|
||||
public class EngramSettingsList : SortableObservableCollection<EngramSettings>, INotifyPropertyChanged
|
||||
{
|
||||
internal EngramSettingsList()
|
||||
{
|
||||
Reset();
|
||||
}
|
||||
|
||||
public EngramSettingsList(EngramEntryList overrideNamedEngramEntries, EngramAutoUnlockList engramEntryAutoUnlocks)
|
||||
{
|
||||
OverrideNamedEngramEntries = overrideNamedEngramEntries;
|
||||
EngramEntryAutoUnlocks = engramEntryAutoUnlocks;
|
||||
|
||||
Reset();
|
||||
}
|
||||
|
||||
public bool IsEnabled
|
||||
{
|
||||
get { return Get<bool>(); }
|
||||
set { Set(value); }
|
||||
}
|
||||
|
||||
[DataMember]
|
||||
public bool OnlyAllowSpecifiedEngrams
|
||||
{
|
||||
get { return Get<bool>(); }
|
||||
set { Set(value); }
|
||||
}
|
||||
|
||||
public EngramEntryList OverrideNamedEngramEntries { get; }
|
||||
|
||||
public EngramAutoUnlockList EngramEntryAutoUnlocks { get; }
|
||||
|
||||
public EngramSettings CreateEngramSetting(string className, string mod, bool knownEngram, bool isTekgram)
|
||||
{
|
||||
return new EngramSettings()
|
||||
{
|
||||
EngramClassName = className,
|
||||
Mod = mod,
|
||||
KnownEngram = knownEngram,
|
||||
IsTekgram = isTekgram,
|
||||
};
|
||||
}
|
||||
|
||||
public void Reset()
|
||||
{
|
||||
this.Clear();
|
||||
|
||||
IsEnabled = false;
|
||||
|
||||
var engrams = GameData.GetEngrams();
|
||||
foreach (var engram in engrams)
|
||||
{
|
||||
var engramSetting = CreateEngramSetting(engram.EngramClassName, engram.Mod, engram.KnownEngram, engram.IsTekgram);
|
||||
engramSetting.EngramLevelRequirement = engram.EngramLevelRequirement;
|
||||
engramSetting.EngramPointsCost = engram.EngramPointsCost;
|
||||
engramSetting.LevelToAutoUnlock = engram.EngramLevelRequirement;
|
||||
this.Add(engramSetting);
|
||||
}
|
||||
}
|
||||
|
||||
public void RenderToView()
|
||||
{
|
||||
Reset();
|
||||
|
||||
if (this.OverrideNamedEngramEntries != null)
|
||||
{
|
||||
foreach (var entry in this.OverrideNamedEngramEntries)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(entry.EngramClassName))
|
||||
continue;
|
||||
|
||||
var engramSettings = this.Where(vi => vi.EngramClassName == entry.EngramClassName).ToArray();
|
||||
if (engramSettings == null || engramSettings.Length == 0)
|
||||
{
|
||||
var engram = GameData.GetEngramForClass(entry.EngramClassName);
|
||||
this.Add(CreateEngramSetting(entry.EngramClassName, engram?.Mod ?? GameData.MOD_UNKNOWN, engram?.KnownEngram ?? false, engram?.IsTekgram ?? false));
|
||||
}
|
||||
|
||||
engramSettings = this.Where(vi => vi.EngramClassName == entry.EngramClassName).ToArray();
|
||||
foreach (var engramSetting in engramSettings)
|
||||
{
|
||||
engramSetting.EngramLevelRequirement = entry.EngramLevelRequirement;
|
||||
engramSetting.EngramPointsCost = entry.EngramPointsCost;
|
||||
engramSetting.EngramHidden = entry.EngramHidden;
|
||||
engramSetting.RemoveEngramPreReq = entry.RemoveEngramPreReq;
|
||||
engramSetting.LevelToAutoUnlock = entry.EngramLevelRequirement;
|
||||
engramSetting.SaveEngramOverride = true;
|
||||
|
||||
if (engramSetting.IsTekgram)
|
||||
{
|
||||
// always make sure that the tekgrams have default values.
|
||||
engramSetting.EngramLevelRequirement = 0;
|
||||
engramSetting.EngramPointsCost = 0;
|
||||
engramSetting.LevelToAutoUnlock = 0;
|
||||
}
|
||||
|
||||
IsEnabled = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (this.EngramEntryAutoUnlocks != null)
|
||||
{
|
||||
foreach (var entry in this.EngramEntryAutoUnlocks)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(entry.EngramClassName))
|
||||
continue;
|
||||
|
||||
var engramSettings = this.Where(vi => vi.EngramClassName == entry.EngramClassName).ToArray();
|
||||
if (engramSettings == null || engramSettings.Length == 0)
|
||||
{
|
||||
var engram = GameData.GetEngramForClass(entry.EngramClassName);
|
||||
this.Add(CreateEngramSetting(entry.EngramClassName, engram?.Mod ?? GameData.MOD_UNKNOWN, engram?.KnownEngram ?? false, engram?.IsTekgram ?? false));
|
||||
}
|
||||
|
||||
engramSettings = this.Where(vi => vi.EngramClassName == entry.EngramClassName).ToArray();
|
||||
foreach (var engramSetting in engramSettings)
|
||||
{
|
||||
engramSetting.EngramAutoUnlock = true;
|
||||
engramSetting.LevelToAutoUnlock = entry.LevelToAutoUnlock;
|
||||
engramSetting.SaveEngramOverride = true;
|
||||
|
||||
IsEnabled = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void RenderToModel()
|
||||
{
|
||||
if (this.OverrideNamedEngramEntries != null)
|
||||
{
|
||||
this.OverrideNamedEngramEntries.Clear();
|
||||
this.OverrideNamedEngramEntries.IsEnabled = false;
|
||||
}
|
||||
|
||||
if (this.EngramEntryAutoUnlocks != null)
|
||||
{
|
||||
this.EngramEntryAutoUnlocks.Clear();
|
||||
this.EngramEntryAutoUnlocks.IsEnabled = false;
|
||||
}
|
||||
|
||||
if (!IsEnabled)
|
||||
return;
|
||||
|
||||
foreach (var entry in this)
|
||||
{
|
||||
if (!entry.IsValid)
|
||||
continue;
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(entry.EngramClassName))
|
||||
{
|
||||
if (this.OverrideNamedEngramEntries != null && entry.ShouldSaveEngramEntry(OnlyAllowSpecifiedEngrams))
|
||||
{
|
||||
this.OverrideNamedEngramEntries.Add(entry.GetEngramEntry());
|
||||
this.OverrideNamedEngramEntries.IsEnabled = true;
|
||||
}
|
||||
|
||||
if (this.EngramEntryAutoUnlocks != null && entry.ShouldSaveEngramAutoUnlock(OnlyAllowSpecifiedEngrams))
|
||||
{
|
||||
this.EngramEntryAutoUnlocks.Add(entry.GetEngramAutoUnlock());
|
||||
this.EngramEntryAutoUnlocks.IsEnabled = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void UpdateForLocalization()
|
||||
{
|
||||
}
|
||||
|
||||
#region INotifyPropertyChanged
|
||||
private Dictionary<string, object> _properties = new Dictionary<string, object>();
|
||||
|
||||
protected T Get<T>([CallerMemberName] string name = null)
|
||||
{
|
||||
object value = null;
|
||||
if (_properties?.TryGetValue(name, out value) ?? false)
|
||||
return value == null ? default : (T)value;
|
||||
return default;
|
||||
}
|
||||
|
||||
protected void Set<T>(T value, [CallerMemberName] string name = null)
|
||||
{
|
||||
if (Equals(value, Get<T>(name)))
|
||||
return;
|
||||
if (_properties == null)
|
||||
_properties = new Dictionary<string, object>();
|
||||
_properties[name] = value;
|
||||
OnPropertyChanged(new PropertyChangedEventArgs(name));
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
||||
[DataContract]
|
||||
public class EngramSettings : DependencyObject
|
||||
{
|
||||
public static readonly DependencyProperty EngramClassNameProperty = DependencyProperty.Register(nameof(EngramClassName), typeof(string), typeof(EngramSettings), new PropertyMetadata(string.Empty));
|
||||
public static readonly DependencyProperty ModProperty = DependencyProperty.Register(nameof(Mod), typeof(string), typeof(EngramSettings), new PropertyMetadata(GameData.MOD_UNKNOWN));
|
||||
public static readonly DependencyProperty KnownEngramProperty = DependencyProperty.Register(nameof(KnownEngram), typeof(bool), typeof(EngramSettings), new PropertyMetadata(false));
|
||||
public static readonly DependencyProperty IsTekgramProperty = DependencyProperty.Register(nameof(IsTekgram), typeof(bool), typeof(EngramSettings), new PropertyMetadata(false));
|
||||
public static readonly DependencyProperty EngramLevelRequirementProperty = DependencyProperty.Register(nameof(EngramLevelRequirement), typeof(int), typeof(EngramSettings), new PropertyMetadata(0));
|
||||
public static readonly DependencyProperty EngramPointsCostProperty = DependencyProperty.Register(nameof(EngramPointsCost), typeof(int), typeof(EngramSettings), new PropertyMetadata(0));
|
||||
public static readonly DependencyProperty EngramHiddenProperty = DependencyProperty.Register(nameof(EngramHidden), typeof(bool), typeof(EngramSettings), new PropertyMetadata(false));
|
||||
public static readonly DependencyProperty RemoveEngramPreReqProperty = DependencyProperty.Register(nameof(RemoveEngramPreReq), typeof(bool), typeof(EngramSettings), new PropertyMetadata(false));
|
||||
public static readonly DependencyProperty EngramAutoUnlockProperty = DependencyProperty.Register(nameof(EngramAutoUnlock), typeof(bool), typeof(EngramSettings), new PropertyMetadata(false));
|
||||
public static readonly DependencyProperty LevelToAutoUnlockProperty = DependencyProperty.Register(nameof(LevelToAutoUnlock), typeof(int), typeof(EngramSettings), new PropertyMetadata(0));
|
||||
public static readonly DependencyProperty SaveEngramOverrideProperty = DependencyProperty.Register(nameof(SaveEngramOverride), typeof(bool), typeof(EngramSettings), new PropertyMetadata(false));
|
||||
|
||||
[DataMember]
|
||||
public string EngramClassName
|
||||
{
|
||||
get { return (string)GetValue(EngramClassNameProperty); }
|
||||
set { SetValue(EngramClassNameProperty, value); }
|
||||
}
|
||||
|
||||
[DataMember]
|
||||
public string Mod
|
||||
{
|
||||
get { return (string)GetValue(ModProperty); }
|
||||
set { SetValue(ModProperty, value); }
|
||||
}
|
||||
|
||||
public bool KnownEngram
|
||||
{
|
||||
get { return (bool)GetValue(KnownEngramProperty); }
|
||||
set { SetValue(KnownEngramProperty, value); }
|
||||
}
|
||||
|
||||
[DataMember]
|
||||
public bool IsTekgram
|
||||
{
|
||||
get { return (bool)GetValue(IsTekgramProperty); }
|
||||
set { SetValue(IsTekgramProperty, value); }
|
||||
}
|
||||
|
||||
public bool IsValid => !string.IsNullOrWhiteSpace(EngramClassName);
|
||||
|
||||
[DataMember]
|
||||
public int EngramLevelRequirement
|
||||
{
|
||||
get { return (int)GetValue(EngramLevelRequirementProperty); }
|
||||
set { SetValue(EngramLevelRequirementProperty, value); }
|
||||
}
|
||||
|
||||
[DataMember]
|
||||
public int EngramPointsCost
|
||||
{
|
||||
get { return (int)GetValue(EngramPointsCostProperty); }
|
||||
set { SetValue(EngramPointsCostProperty, value); }
|
||||
}
|
||||
|
||||
[DataMember]
|
||||
public bool EngramHidden
|
||||
{
|
||||
get { return (bool)GetValue(EngramHiddenProperty); }
|
||||
set { SetValue(EngramHiddenProperty, value); }
|
||||
}
|
||||
|
||||
[DataMember]
|
||||
public bool RemoveEngramPreReq
|
||||
{
|
||||
get { return (bool)GetValue(RemoveEngramPreReqProperty); }
|
||||
set { SetValue(RemoveEngramPreReqProperty, value); }
|
||||
}
|
||||
|
||||
[DataMember]
|
||||
public bool EngramAutoUnlock
|
||||
{
|
||||
get { return (bool)GetValue(EngramAutoUnlockProperty); }
|
||||
set { SetValue(EngramAutoUnlockProperty, value); }
|
||||
}
|
||||
|
||||
[DataMember]
|
||||
public int LevelToAutoUnlock
|
||||
{
|
||||
get { return (int)GetValue(LevelToAutoUnlockProperty); }
|
||||
set { SetValue(LevelToAutoUnlockProperty, value); }
|
||||
}
|
||||
|
||||
[DataMember]
|
||||
public bool SaveEngramOverride
|
||||
{
|
||||
get { return (bool)GetValue(SaveEngramOverrideProperty); }
|
||||
set { SetValue(SaveEngramOverrideProperty, value); }
|
||||
}
|
||||
|
||||
public string DisplayName => GameData.FriendlyEngramNameForClass(EngramClassName);
|
||||
|
||||
public string DisplayMod => GameData.FriendlyNameForClass($"Mod_{Mod}", true) ?? Mod;
|
||||
|
||||
public bool ShouldSaveEngramEntry(bool onlyAllowSpecifiedEngrams)
|
||||
{
|
||||
if (onlyAllowSpecifiedEngrams)
|
||||
return SaveEngramOverride;
|
||||
|
||||
var engramEntry = GameData.GetEngramForClass(EngramClassName);
|
||||
if (engramEntry == null)
|
||||
engramEntry = new Engram();
|
||||
|
||||
var engramLevelRequirement = IsTekgram ? 0 : EngramLevelRequirement;
|
||||
var engramPointsCost = IsTekgram ? 0 : EngramPointsCost;
|
||||
var engramHidden = EngramHidden;
|
||||
var removeEngramPreReq = RemoveEngramPreReq;
|
||||
|
||||
return (!engramLevelRequirement.Equals(engramEntry.EngramLevelRequirement) ||
|
||||
!engramPointsCost.Equals(engramEntry.EngramPointsCost) ||
|
||||
engramHidden ||
|
||||
removeEngramPreReq);
|
||||
}
|
||||
|
||||
public bool ShouldSaveEngramAutoUnlock(bool onlyAllowSpecifiedEngrams)
|
||||
{
|
||||
if (onlyAllowSpecifiedEngrams && !SaveEngramOverride)
|
||||
return false;
|
||||
|
||||
return EngramAutoUnlock;
|
||||
}
|
||||
|
||||
public EngramEntry GetEngramEntry()
|
||||
{
|
||||
var engramEntry = new EngramEntry() { EngramClassName = this.EngramClassName, EngramLevelRequirement = this.EngramLevelRequirement, EngramPointsCost = this.EngramPointsCost, EngramHidden = this.EngramHidden, RemoveEngramPreReq = this.RemoveEngramPreReq };
|
||||
if (IsTekgram)
|
||||
{
|
||||
// always make sure that the tekgrams have default values.
|
||||
engramEntry.EngramLevelRequirement = 0;
|
||||
engramEntry.EngramPointsCost = 0;
|
||||
}
|
||||
return engramEntry;
|
||||
}
|
||||
|
||||
public EngramAutoUnlock GetEngramAutoUnlock()
|
||||
{
|
||||
var engramEntry = new EngramAutoUnlock() { EngramClassName = this.EngramClassName, LevelToAutoUnlock = this.LevelToAutoUnlock };
|
||||
return engramEntry;
|
||||
}
|
||||
|
||||
#region Sort Properties
|
||||
public string SaveEngramOverrideSort => $"{SaveEngramOverride}|{IsTekgram}|{DisplayName}|{Mod}";
|
||||
public string NameSort => $"{DisplayName}|{Mod}";
|
||||
public string ModSort => $"{Mod}|{IsTekgram}|{DisplayName}";
|
||||
public string IsTekgramSort => $"{IsTekgram}|{DisplayName}|{Mod}";
|
||||
public string EngramLevelRequirementSort => $"{EngramLevelRequirement:0000000000}|{IsTekgram}|{DisplayName}|{Mod}";
|
||||
public string EngramPointsCostSort => $"{EngramPointsCost:0000000000}|{IsTekgram}|{DisplayName}|{Mod}";
|
||||
public string EngramHiddenSort => $"{EngramHidden}|{IsTekgram}|{DisplayName}|{Mod}";
|
||||
public string RemoveEngramPreReqSort => $"{RemoveEngramPreReq}|{IsTekgram}|{DisplayName}|{Mod}";
|
||||
public string EngramAutoUnlockSort => $"{EngramAutoUnlock}|{IsTekgram}|{DisplayName}|{Mod}";
|
||||
public string LevelToAutoUnlockSort => $"{LevelToAutoUnlock:0000000000}|{IsTekgram}|{DisplayName}|{Mod}";
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
48
src/ARKServerManager/Lib/ViewModel/MapSpawner.cs
Normal file
48
src/ARKServerManager/Lib/ViewModel/MapSpawner.cs
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
using System;
|
||||
using System.Windows;
|
||||
|
||||
namespace ServerManagerTool.Lib.ViewModel
|
||||
{
|
||||
public class MapSpawner : DependencyObject
|
||||
{
|
||||
public static readonly DependencyProperty ClassNameProperty = DependencyProperty.Register(nameof(ClassName), typeof(string), typeof(MapSpawner), new PropertyMetadata(string.Empty));
|
||||
public static readonly DependencyProperty ModProperty = DependencyProperty.Register(nameof(Mod), typeof(string), typeof(MapSpawner), new PropertyMetadata(String.Empty));
|
||||
public static readonly DependencyProperty KnownSpawnerProperty = DependencyProperty.Register(nameof(KnownSpawner), typeof(bool), typeof(MapSpawner), new PropertyMetadata(false));
|
||||
|
||||
public string ClassName
|
||||
{
|
||||
get { return (string)GetValue(ClassNameProperty); }
|
||||
set { SetValue(ClassNameProperty, value); }
|
||||
}
|
||||
|
||||
public string Mod
|
||||
{
|
||||
get { return (string)GetValue(ModProperty); }
|
||||
set { SetValue(ModProperty, value); }
|
||||
}
|
||||
|
||||
public bool KnownSpawner
|
||||
{
|
||||
get { return (bool)GetValue(KnownSpawnerProperty); }
|
||||
set { SetValue(KnownSpawnerProperty, value); }
|
||||
}
|
||||
|
||||
public string DisplayName => GameData.FriendlyMapSpawnerNameForClass(ClassName);
|
||||
|
||||
public string DisplayMod => GameData.FriendlyNameForClass($"Mod_{Mod}", true) ?? Mod;
|
||||
|
||||
public MapSpawner Duplicate()
|
||||
{
|
||||
var properties = this.GetType().GetProperties();
|
||||
|
||||
var result = new MapSpawner();
|
||||
foreach (var prop in properties)
|
||||
{
|
||||
if (prop.CanWrite)
|
||||
prop.SetValue(result, prop.GetValue(this));
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
319
src/ARKServerManager/Lib/ViewModel/NPCSpawnSettings.cs
Normal file
319
src/ARKServerManager/Lib/ViewModel/NPCSpawnSettings.cs
Normal file
|
|
@ -0,0 +1,319 @@
|
|||
using ServerManagerTool.Common.Model;
|
||||
using ServerManagerTool.Enums;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using System.Windows;
|
||||
|
||||
namespace ServerManagerTool.Lib.ViewModel
|
||||
{
|
||||
public class NPCSpawnSettingsList : SortableObservableCollection<NPCSpawnSettings>
|
||||
{
|
||||
public NPCSpawnContainerList<NPCSpawnContainer> ConfigAddNPCSpawnEntriesContainer { get; }
|
||||
public NPCSpawnContainerList<NPCSpawnContainer> ConfigSubtractNPCSpawnEntriesContainer { get; }
|
||||
public NPCSpawnContainerList<NPCSpawnContainer> ConfigOverrideNPCSpawnEntriesContainer { get; }
|
||||
|
||||
public NPCSpawnSettingsList()
|
||||
{
|
||||
Reset();
|
||||
}
|
||||
|
||||
public NPCSpawnSettingsList(NPCSpawnContainerList<NPCSpawnContainer> configAddNPCSpawnEntriesContainer,
|
||||
NPCSpawnContainerList<NPCSpawnContainer> configSubtractNPCSpawnEntriesContainer,
|
||||
NPCSpawnContainerList<NPCSpawnContainer> configOverrideNPCSpawnEntriesContainer)
|
||||
{
|
||||
ConfigAddNPCSpawnEntriesContainer = configAddNPCSpawnEntriesContainer;
|
||||
ConfigSubtractNPCSpawnEntriesContainer = configSubtractNPCSpawnEntriesContainer;
|
||||
ConfigOverrideNPCSpawnEntriesContainer = configOverrideNPCSpawnEntriesContainer;
|
||||
|
||||
Reset();
|
||||
}
|
||||
|
||||
public void Reset()
|
||||
{
|
||||
this.Clear();
|
||||
}
|
||||
|
||||
public void RenderToView()
|
||||
{
|
||||
Reset();
|
||||
|
||||
foreach (var entry in this.ConfigAddNPCSpawnEntriesContainer)
|
||||
{
|
||||
if (!entry.IsValid)
|
||||
continue;
|
||||
|
||||
var spawnSettings = new NPCSpawnSettings
|
||||
{
|
||||
UniqueId = entry.UniqueId,
|
||||
ContainerType = NPCSpawnContainerType.Add,
|
||||
NPCSpawnEntriesContainerClassString = entry.NPCSpawnEntriesContainerClassString,
|
||||
};
|
||||
foreach (var item in entry.NPCSpawnEntries)
|
||||
{
|
||||
spawnSettings.NPCSpawnEntrySettings.Add(new NPCSpawnEntrySettings
|
||||
{
|
||||
AnEntryName = item.AnEntryName,
|
||||
NPCClassString = item.NPCsToSpawnStrings,
|
||||
EntryWeight = item.EntryWeight,
|
||||
});
|
||||
}
|
||||
|
||||
foreach (var item in entry.NPCSpawnLimits)
|
||||
{
|
||||
var temp = spawnSettings.NPCSpawnEntrySettings.FirstOrDefault(i => i.NPCClassString.Equals(item.NPCClassString));
|
||||
if (temp == null)
|
||||
continue;
|
||||
|
||||
temp.MaxPercentageOfDesiredNumToAllow = item.MaxPercentageOfDesiredNumToAllow;
|
||||
}
|
||||
|
||||
this.Add(spawnSettings);
|
||||
}
|
||||
|
||||
foreach (var entry in this.ConfigSubtractNPCSpawnEntriesContainer)
|
||||
{
|
||||
if (!entry.IsValid)
|
||||
continue;
|
||||
|
||||
var spawnSettings = new NPCSpawnSettings
|
||||
{
|
||||
UniqueId = entry.UniqueId,
|
||||
ContainerType = NPCSpawnContainerType.Subtract,
|
||||
NPCSpawnEntriesContainerClassString = entry.NPCSpawnEntriesContainerClassString,
|
||||
};
|
||||
foreach (var item in entry.NPCSpawnEntries)
|
||||
{
|
||||
spawnSettings.NPCSpawnEntrySettings.Add(new NPCSpawnEntrySettings
|
||||
{
|
||||
AnEntryName = item.AnEntryName,
|
||||
NPCClassString = item.NPCsToSpawnStrings,
|
||||
EntryWeight = item.EntryWeight,
|
||||
});
|
||||
}
|
||||
|
||||
foreach (var item in entry.NPCSpawnLimits)
|
||||
{
|
||||
var temp = spawnSettings.NPCSpawnEntrySettings.FirstOrDefault(i => i.NPCClassString.Equals(item.NPCClassString));
|
||||
if (temp == null)
|
||||
continue;
|
||||
|
||||
temp.MaxPercentageOfDesiredNumToAllow = item.MaxPercentageOfDesiredNumToAllow;
|
||||
}
|
||||
|
||||
this.Add(spawnSettings);
|
||||
}
|
||||
|
||||
foreach (var entry in this.ConfigOverrideNPCSpawnEntriesContainer)
|
||||
{
|
||||
if (!entry.IsValid)
|
||||
continue;
|
||||
|
||||
var spawnSettings = new NPCSpawnSettings
|
||||
{
|
||||
UniqueId = entry.UniqueId,
|
||||
ContainerType = NPCSpawnContainerType.Override,
|
||||
NPCSpawnEntriesContainerClassString = entry.NPCSpawnEntriesContainerClassString,
|
||||
};
|
||||
foreach (var item in entry.NPCSpawnEntries)
|
||||
{
|
||||
spawnSettings.NPCSpawnEntrySettings.Add(new NPCSpawnEntrySettings
|
||||
{
|
||||
AnEntryName = item.AnEntryName,
|
||||
NPCClassString = item.NPCsToSpawnStrings,
|
||||
EntryWeight = item.EntryWeight,
|
||||
});
|
||||
}
|
||||
|
||||
foreach (var item in entry.NPCSpawnLimits)
|
||||
{
|
||||
var temp = spawnSettings.NPCSpawnEntrySettings.FirstOrDefault(i => i.NPCClassString.Equals(item.NPCClassString));
|
||||
if (temp == null)
|
||||
continue;
|
||||
|
||||
temp.MaxPercentageOfDesiredNumToAllow = item.MaxPercentageOfDesiredNumToAllow;
|
||||
}
|
||||
|
||||
this.Add(spawnSettings);
|
||||
}
|
||||
}
|
||||
|
||||
public void RenderToModel()
|
||||
{
|
||||
this.ConfigAddNPCSpawnEntriesContainer.Clear();
|
||||
this.ConfigSubtractNPCSpawnEntriesContainer.Clear();
|
||||
this.ConfigOverrideNPCSpawnEntriesContainer.Clear();
|
||||
|
||||
this.ConfigAddNPCSpawnEntriesContainer.IsEnabled = false;
|
||||
this.ConfigSubtractNPCSpawnEntriesContainer.IsEnabled = false;
|
||||
this.ConfigOverrideNPCSpawnEntriesContainer.IsEnabled = false;
|
||||
|
||||
foreach (var entry in this)
|
||||
{
|
||||
if (!entry.IsValid)
|
||||
continue;
|
||||
|
||||
var spawnContainer = new NPCSpawnContainer
|
||||
{
|
||||
UniqueId = entry.UniqueId,
|
||||
NPCSpawnEntriesContainerClassString = entry.NPCSpawnEntriesContainerClassString,
|
||||
};
|
||||
spawnContainer.NPCSpawnEntries.AddRange(entry.NPCSpawnEntrySettings.Where(s => s.IsValid).Select(s => new NPCSpawnEntry
|
||||
{
|
||||
AnEntryName = string.IsNullOrWhiteSpace(s.AnEntryName) ? string.Empty : s.AnEntryName,
|
||||
EntryWeight = s.EntryWeight,
|
||||
NPCsToSpawnStrings = s.NPCClassString
|
||||
}));
|
||||
spawnContainer.NPCSpawnLimits.AddRange(entry.NPCSpawnEntrySettings.Where(s => s.IsValid).Select(s => new NPCSpawnLimit
|
||||
{
|
||||
NPCClassString = s.NPCClassString,
|
||||
MaxPercentageOfDesiredNumToAllow = s.MaxPercentageOfDesiredNumToAllow
|
||||
}));
|
||||
|
||||
switch (entry.ContainerType)
|
||||
{
|
||||
case NPCSpawnContainerType.Add:
|
||||
this.ConfigAddNPCSpawnEntriesContainer.Add(spawnContainer);
|
||||
this.ConfigAddNPCSpawnEntriesContainer.IsEnabled = true;
|
||||
break;
|
||||
|
||||
case NPCSpawnContainerType.Subtract:
|
||||
this.ConfigSubtractNPCSpawnEntriesContainer.Add(spawnContainer);
|
||||
this.ConfigSubtractNPCSpawnEntriesContainer.IsEnabled = true;
|
||||
break;
|
||||
|
||||
case NPCSpawnContainerType.Override:
|
||||
this.ConfigOverrideNPCSpawnEntriesContainer.Add(spawnContainer);
|
||||
this.ConfigOverrideNPCSpawnEntriesContainer.IsEnabled = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void UpdateForLocalization()
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
public class NPCSpawnSettings : DependencyObject, IEnumerable<NPCSpawnEntrySettings>
|
||||
{
|
||||
public NPCSpawnSettings()
|
||||
{
|
||||
NPCSpawnEntrySettings = new ObservableCollection<NPCSpawnEntrySettings>();
|
||||
}
|
||||
|
||||
public Guid UniqueId = Guid.NewGuid();
|
||||
|
||||
public static readonly DependencyProperty ContainerTypeProperty = DependencyProperty.Register(nameof(ContainerType), typeof(NPCSpawnContainerType), typeof(NPCSpawnSettings), new PropertyMetadata(NPCSpawnContainerType.Override));
|
||||
public NPCSpawnContainerType ContainerType
|
||||
{
|
||||
get { return (NPCSpawnContainerType)GetValue(ContainerTypeProperty); }
|
||||
set
|
||||
{
|
||||
SetValue(ContainerTypeProperty, value);
|
||||
SetShowColumns();
|
||||
}
|
||||
}
|
||||
|
||||
public static readonly DependencyProperty NPCSpawnEntriesContainerClassStringProperty = DependencyProperty.Register(nameof(NPCSpawnEntriesContainerClassString), typeof(string), typeof(NPCSpawnSettings), new PropertyMetadata(string.Empty));
|
||||
public string NPCSpawnEntriesContainerClassString
|
||||
{
|
||||
get { return (string)GetValue(NPCSpawnEntriesContainerClassStringProperty); }
|
||||
set { SetValue(NPCSpawnEntriesContainerClassStringProperty, value); }
|
||||
}
|
||||
|
||||
public static readonly DependencyProperty NPCSpawnEntrySettingsProperty = DependencyProperty.Register(nameof(NPCSpawnEntrySettings), typeof(ObservableCollection<NPCSpawnEntrySettings>), typeof(NPCSpawnSettings), new PropertyMetadata(null));
|
||||
public ObservableCollection<NPCSpawnEntrySettings> NPCSpawnEntrySettings
|
||||
{
|
||||
get { return (ObservableCollection<NPCSpawnEntrySettings>)GetValue(NPCSpawnEntrySettingsProperty); }
|
||||
set { SetValue(NPCSpawnEntrySettingsProperty, value); }
|
||||
}
|
||||
|
||||
public string DisplayName => GameData.FriendlyMapSpawnerNameForClass(NPCSpawnEntriesContainerClassString);
|
||||
|
||||
public bool IsValid => !string.IsNullOrWhiteSpace(NPCSpawnEntriesContainerClassString);
|
||||
|
||||
public static readonly DependencyProperty ShowEntryNameColumnProperty = DependencyProperty.Register(nameof(ShowEntryNameColumn), typeof(bool), typeof(NPCSpawnSettings), new PropertyMetadata(true));
|
||||
public bool ShowEntryNameColumn
|
||||
{
|
||||
get { return (bool)GetValue(ShowEntryNameColumnProperty); }
|
||||
set { SetValue(ShowEntryNameColumnProperty, value); }
|
||||
}
|
||||
|
||||
public static readonly DependencyProperty ShowClassStringColumnProperty = DependencyProperty.Register(nameof(ShowClassStringColumn), typeof(bool), typeof(NPCSpawnSettings), new PropertyMetadata(true));
|
||||
public bool ShowClassStringColumn
|
||||
{
|
||||
get { return (bool)GetValue(ShowClassStringColumnProperty); }
|
||||
set { SetValue(ShowClassStringColumnProperty, value); }
|
||||
}
|
||||
|
||||
public static readonly DependencyProperty ShowEntryWeightColumnProperty = DependencyProperty.Register(nameof(ShowEntryWeightColumn), typeof(bool), typeof(NPCSpawnSettings), new PropertyMetadata(true));
|
||||
public bool ShowEntryWeightColumn
|
||||
{
|
||||
get { return (bool)GetValue(ShowEntryWeightColumnProperty); }
|
||||
set { SetValue(ShowEntryWeightColumnProperty, value); }
|
||||
}
|
||||
|
||||
public static readonly DependencyProperty ShowMaxPercentageColumnProperty = DependencyProperty.Register(nameof(ShowMaxPercentageColumn), typeof(bool), typeof(NPCSpawnSettings), new PropertyMetadata(true));
|
||||
public bool ShowMaxPercentageColumn
|
||||
{
|
||||
get { return (bool)GetValue(ShowMaxPercentageColumnProperty); }
|
||||
set { SetValue(ShowMaxPercentageColumnProperty, value); }
|
||||
}
|
||||
|
||||
private void SetShowColumns()
|
||||
{
|
||||
ShowEntryNameColumn = ContainerType != NPCSpawnContainerType.Subtract;
|
||||
ShowClassStringColumn = true;
|
||||
ShowEntryWeightColumn = ContainerType != NPCSpawnContainerType.Subtract;
|
||||
ShowMaxPercentageColumn = ContainerType != NPCSpawnContainerType.Subtract;
|
||||
}
|
||||
|
||||
public IEnumerator<NPCSpawnEntrySettings> GetEnumerator()
|
||||
{
|
||||
return NPCSpawnEntrySettings.GetEnumerator();
|
||||
}
|
||||
|
||||
IEnumerator IEnumerable.GetEnumerator()
|
||||
{
|
||||
return NPCSpawnEntrySettings.GetEnumerator();
|
||||
}
|
||||
}
|
||||
|
||||
public class NPCSpawnEntrySettings : DependencyObject
|
||||
{
|
||||
public static readonly DependencyProperty AnEntryNameProperty = DependencyProperty.Register(nameof(AnEntryName), typeof(string), typeof(NPCSpawnEntrySettings), new PropertyMetadata(string.Empty));
|
||||
public string AnEntryName
|
||||
{
|
||||
get { return (string)GetValue(AnEntryNameProperty); }
|
||||
set { SetValue(AnEntryNameProperty, value); }
|
||||
}
|
||||
|
||||
public static readonly DependencyProperty NPCClassStringProperty = DependencyProperty.Register(nameof(NPCClassString), typeof(string), typeof(NPCSpawnEntrySettings), new PropertyMetadata(string.Empty));
|
||||
public string NPCClassString
|
||||
{
|
||||
get { return (string)GetValue(NPCClassStringProperty); }
|
||||
set { SetValue(NPCClassStringProperty, value); }
|
||||
}
|
||||
|
||||
public static readonly DependencyProperty EntryWeightProperty = DependencyProperty.Register(nameof(EntryWeight), typeof(float), typeof(NPCSpawnEntrySettings), new PropertyMetadata(1.0f));
|
||||
public float EntryWeight
|
||||
{
|
||||
get { return (float)GetValue(EntryWeightProperty); }
|
||||
set { SetValue(EntryWeightProperty, value); }
|
||||
}
|
||||
|
||||
public static readonly DependencyProperty MaxPercentageOfDesiredNumToAllowProperty = DependencyProperty.Register(nameof(MaxPercentageOfDesiredNumToAllow), typeof(float), typeof(NPCSpawnEntrySettings), new PropertyMetadata(1.0f));
|
||||
public float MaxPercentageOfDesiredNumToAllow
|
||||
{
|
||||
get { return (float)GetValue(MaxPercentageOfDesiredNumToAllowProperty); }
|
||||
set { SetValue(MaxPercentageOfDesiredNumToAllowProperty, value); }
|
||||
}
|
||||
|
||||
public string DisplayName => GameData.FriendlyCreatureNameForClass(NPCClassString);
|
||||
|
||||
public bool IsValid => !string.IsNullOrWhiteSpace(NPCClassString);
|
||||
}
|
||||
}
|
||||
160
src/ARKServerManager/Lib/ViewModel/PlayerInfo.cs
Normal file
160
src/ARKServerManager/Lib/ViewModel/PlayerInfo.cs
Normal file
|
|
@ -0,0 +1,160 @@
|
|||
using ArkData;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.IO;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
namespace ServerManagerTool.Lib.ViewModel.RCON
|
||||
{
|
||||
public class PlayerInfo : INotifyPropertyChanged
|
||||
{
|
||||
public PlayerInfo()
|
||||
{
|
||||
PlayerId = string.Empty;
|
||||
PlayerName = string.Empty;
|
||||
CharacterName = string.Empty;
|
||||
IsOnline = false;
|
||||
IsAdmin = false;
|
||||
IsWhitelisted = false;
|
||||
TribeName = string.Empty;
|
||||
LastUpdated = DateTime.MinValue;
|
||||
IsValid = true;
|
||||
PlayerData = null;
|
||||
}
|
||||
|
||||
public string PlayerId
|
||||
{
|
||||
get { return Get<string>(); }
|
||||
set { Set(value); }
|
||||
}
|
||||
public string PlayerName
|
||||
{
|
||||
get { return Get<string>(); }
|
||||
set
|
||||
{
|
||||
Set(value);
|
||||
|
||||
PlayerNameFilterString = value?.ToLower();
|
||||
}
|
||||
}
|
||||
public string PlayerNameFilterString
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
public long CharacterId
|
||||
{
|
||||
get { return Get<long>(); }
|
||||
set { Set(value); }
|
||||
}
|
||||
public string CharacterName
|
||||
{
|
||||
get { return Get<string>(); }
|
||||
set
|
||||
{
|
||||
Set(value);
|
||||
|
||||
CharacterNameFilterString = value?.ToLower();
|
||||
}
|
||||
}
|
||||
public string CharacterNameFilterString
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
public bool IsOnline
|
||||
{
|
||||
get { return Get<bool>(); }
|
||||
set { Set(value); }
|
||||
}
|
||||
public bool IsAdmin
|
||||
{
|
||||
get { return Get<bool>(); }
|
||||
set { Set(value); }
|
||||
}
|
||||
public bool IsWhitelisted
|
||||
{
|
||||
get { return Get<bool>(); }
|
||||
set { Set(value); }
|
||||
}
|
||||
public string TribeName
|
||||
{
|
||||
get { return Get<string>(); }
|
||||
set
|
||||
{
|
||||
Set(value);
|
||||
|
||||
TribeNameFilterString = value?.ToLower();
|
||||
}
|
||||
}
|
||||
public string TribeNameFilterString
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
public DateTime LastUpdated
|
||||
{
|
||||
get { return Get<DateTime>(); }
|
||||
set { Set(value); }
|
||||
}
|
||||
public bool IsValid
|
||||
{
|
||||
get { return Get<bool>(); }
|
||||
set { Set(value); }
|
||||
}
|
||||
public PlayerData PlayerData
|
||||
{
|
||||
get { return Get<PlayerData>(); }
|
||||
set { Set(value); }
|
||||
}
|
||||
|
||||
public void UpdateData(PlayerData playerData)
|
||||
{
|
||||
this.PlayerData = playerData;
|
||||
this.PlayerId = playerData?.PlayerId;
|
||||
this.CharacterId = playerData?.CharacterId ?? 0L;
|
||||
this.CharacterName = playerData?.CharacterName;
|
||||
this.TribeName = playerData?.Tribe?.Name;
|
||||
this.LastUpdated = playerData?.FileUpdated ?? DateTime.MinValue;
|
||||
}
|
||||
|
||||
public void UpdatePlatformData(PlayerData playerData)
|
||||
{
|
||||
if (playerData == null)
|
||||
return;
|
||||
|
||||
playerData.PlayerName = PlayerData?.PlayerName;
|
||||
playerData.LastPlatformUpdateUtc = PlayerData?.LastPlatformUpdateUtc ?? DateTime.MinValue;
|
||||
}
|
||||
|
||||
#region INotifyPropertyChanged
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
|
||||
private Dictionary<string, object> _properties = new Dictionary<string, object>();
|
||||
|
||||
protected T Get<T>([CallerMemberName] string name = null)
|
||||
{
|
||||
object value = null;
|
||||
if (_properties?.TryGetValue(name, out value) ?? false)
|
||||
return value == null ? default : (T)value;
|
||||
return default;
|
||||
}
|
||||
|
||||
protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)
|
||||
{
|
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
||||
}
|
||||
|
||||
protected void Set<T>(T value, [CallerMemberName] string name = null)
|
||||
{
|
||||
if (Equals(value, Get<T>(name)))
|
||||
return;
|
||||
if (_properties == null)
|
||||
_properties = new Dictionary<string, object>();
|
||||
_properties[name] = value;
|
||||
OnPropertyChanged(name);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
56
src/ARKServerManager/Lib/ViewModel/PrimalItem.cs
Normal file
56
src/ARKServerManager/Lib/ViewModel/PrimalItem.cs
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
using ServerManagerTool.Enums;
|
||||
using System;
|
||||
using System.Windows;
|
||||
|
||||
namespace ServerManagerTool.Lib.ViewModel
|
||||
{
|
||||
public class PrimalItem : DependencyObject
|
||||
{
|
||||
public static readonly DependencyProperty ClassNameProperty = DependencyProperty.Register(nameof(ClassName), typeof(string), typeof(PrimalItem), new PropertyMetadata(String.Empty));
|
||||
public static readonly DependencyProperty ModProperty = DependencyProperty.Register(nameof(Mod), typeof(string), typeof(PrimalItem), new PropertyMetadata(String.Empty));
|
||||
public static readonly DependencyProperty KnownItemProperty = DependencyProperty.Register(nameof(KnownItem), typeof(bool), typeof(PrimalItem), new PropertyMetadata(false));
|
||||
public static readonly DependencyProperty CategoryProperty = DependencyProperty.Register(nameof(Category), typeof(string), typeof(PrimalItem), new PropertyMetadata(String.Empty));
|
||||
|
||||
public string ClassName
|
||||
{
|
||||
get { return (string)GetValue(ClassNameProperty); }
|
||||
set { SetValue(ClassNameProperty, value); }
|
||||
}
|
||||
|
||||
public string Mod
|
||||
{
|
||||
get { return (string)GetValue(ModProperty); }
|
||||
set { SetValue(ModProperty, value); }
|
||||
}
|
||||
|
||||
public bool KnownItem
|
||||
{
|
||||
get { return (bool)GetValue(KnownItemProperty); }
|
||||
set { SetValue(KnownItemProperty, value); }
|
||||
}
|
||||
|
||||
public string Category
|
||||
{
|
||||
get { return (string)GetValue(CategoryProperty); }
|
||||
set { SetValue(CategoryProperty, value); }
|
||||
}
|
||||
|
||||
public string DisplayName => GameData.FriendlyItemNameForClass(ClassName);
|
||||
|
||||
public string DisplayMod => GameData.FriendlyNameForClass($"Mod_{Mod}", true) ?? Mod;
|
||||
|
||||
public PrimalItem Duplicate()
|
||||
{
|
||||
var properties = this.GetType().GetProperties();
|
||||
|
||||
var result = new PrimalItem();
|
||||
foreach (var prop in properties)
|
||||
{
|
||||
if (prop.CanWrite)
|
||||
prop.SetValue(result, prop.GetValue(this));
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
48
src/ARKServerManager/Lib/ViewModel/SupplyCrate.cs
Normal file
48
src/ARKServerManager/Lib/ViewModel/SupplyCrate.cs
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
using System;
|
||||
using System.Windows;
|
||||
|
||||
namespace ServerManagerTool.Lib.ViewModel
|
||||
{
|
||||
public class SupplyCrate : DependencyObject
|
||||
{
|
||||
public static readonly DependencyProperty ClassNameProperty = DependencyProperty.Register(nameof(ClassName), typeof(string), typeof(SupplyCrate), new PropertyMetadata(string.Empty));
|
||||
public static readonly DependencyProperty ModProperty = DependencyProperty.Register(nameof(Mod), typeof(string), typeof(SupplyCrate), new PropertyMetadata(String.Empty));
|
||||
public static readonly DependencyProperty KnownSupplyCrateProperty = DependencyProperty.Register(nameof(KnownSupplyCrate), typeof(bool), typeof(SupplyCrate), new PropertyMetadata(false));
|
||||
|
||||
public string ClassName
|
||||
{
|
||||
get { return (string)GetValue(ClassNameProperty); }
|
||||
set { SetValue(ClassNameProperty, value); }
|
||||
}
|
||||
|
||||
public string Mod
|
||||
{
|
||||
get { return (string)GetValue(ModProperty); }
|
||||
set { SetValue(ModProperty, value); }
|
||||
}
|
||||
|
||||
public bool KnownSupplyCrate
|
||||
{
|
||||
get { return (bool)GetValue(KnownSupplyCrateProperty); }
|
||||
set { SetValue(KnownSupplyCrateProperty, value); }
|
||||
}
|
||||
|
||||
public string DisplayName => GameData.FriendlySupplyCrateNameForClass(ClassName);
|
||||
|
||||
public string DisplayMod => GameData.FriendlyNameForClass($"Mod_{Mod}", true) ?? Mod;
|
||||
|
||||
public SupplyCrate Duplicate()
|
||||
{
|
||||
var properties = this.GetType().GetProperties();
|
||||
|
||||
var result = new SupplyCrate();
|
||||
foreach (var prop in properties)
|
||||
{
|
||||
if (prop.CanWrite)
|
||||
prop.SetValue(result, prop.GetValue(this));
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
25
src/ARKServerManager/Lib/ViewModel/SupplyCrateSettings.cs
Normal file
25
src/ARKServerManager/Lib/ViewModel/SupplyCrateSettings.cs
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
using System.Windows;
|
||||
|
||||
namespace ServerManagerTool.Lib.ViewModel
|
||||
{
|
||||
public class SupplyCrateItemEntrySettings : DependencyObject
|
||||
{
|
||||
public static readonly DependencyProperty ItemClassStringProperty = DependencyProperty.Register(nameof(ItemClassString), typeof(string), typeof(SupplyCrateItemEntrySettings), new PropertyMetadata(string.Empty));
|
||||
public string ItemClassString
|
||||
{
|
||||
get { return (string)GetValue(ItemClassStringProperty); }
|
||||
set { SetValue(ItemClassStringProperty, value); }
|
||||
}
|
||||
|
||||
public static readonly DependencyProperty ItemWeightProperty = DependencyProperty.Register(nameof(ItemWeight), typeof(float), typeof(SupplyCrateItemEntrySettings), new PropertyMetadata(1.0f));
|
||||
public float ItemWeight
|
||||
{
|
||||
get { return (float)GetValue(ItemWeightProperty); }
|
||||
set { SetValue(ItemWeightProperty, value); }
|
||||
}
|
||||
|
||||
public string DisplayName => GameData.FriendlySupplyCrateNameForClass(ItemClassString);
|
||||
|
||||
public bool IsValid => !string.IsNullOrWhiteSpace(ItemClassString);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue