first commit
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
namespace NitroxModel_Subnautica.DataStructures.GameLogic.Creatures.Actions
|
||||
{
|
||||
public interface SerializableCreatureAction
|
||||
{
|
||||
CreatureAction GetCreatureAction(GameObject gameObject);
|
||||
}
|
||||
|
||||
// SerializableCreatureAction is not implemented yet but test require that at least one class inherits it
|
||||
[Serializable]
|
||||
public class EmptyCreatureAction: SerializableCreatureAction
|
||||
{
|
||||
public CreatureAction GetCreatureAction(GameObject gameObject) => null;
|
||||
}
|
||||
}
|
@@ -0,0 +1,51 @@
|
||||
using System;
|
||||
using System.Runtime.Serialization;
|
||||
using NitroxModel.DataStructures;
|
||||
using NitroxModel.DataStructures.Unity;
|
||||
using NitroxModel.DataStructures.Util;
|
||||
|
||||
namespace NitroxModel_Subnautica.DataStructures.GameLogic
|
||||
{
|
||||
[Serializable]
|
||||
[DataContract]
|
||||
public class CyclopsDamageInfoData
|
||||
{
|
||||
[DataMember(Order = 1)]
|
||||
public NitroxId ReceiverId { get; set; }
|
||||
|
||||
[DataMember(Order = 2)]
|
||||
public Optional<NitroxId> DealerId { get; set; }
|
||||
|
||||
[DataMember(Order = 3)]
|
||||
public float OriginalDamage { get; set; }
|
||||
|
||||
[DataMember(Order = 4)]
|
||||
public float Damage { get; set; }
|
||||
|
||||
[DataMember(Order = 5)]
|
||||
public NitroxVector3 Position { get; set; }
|
||||
|
||||
[DataMember(Order = 6)]
|
||||
public DamageType Type { get; set; }
|
||||
|
||||
protected CyclopsDamageInfoData()
|
||||
{
|
||||
// Constructor for serialization. Has to be "protected" for json serialization.
|
||||
}
|
||||
|
||||
public CyclopsDamageInfoData(NitroxId receiverId, Optional<NitroxId> dealerId, float originalDamage, float damage, NitroxVector3 position, DamageType type)
|
||||
{
|
||||
ReceiverId = receiverId;
|
||||
DealerId = dealerId;
|
||||
OriginalDamage = originalDamage;
|
||||
Damage = damage;
|
||||
Position = position;
|
||||
Type = type;
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return $"[CyclopsDamageInfoData - ReceiverId: {ReceiverId} DealerId:{DealerId} OriginalDamage: {OriginalDamage} Damage: {Damage} Position: {Position} Type: {Type}}}]";
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,41 @@
|
||||
using System;
|
||||
using System.Runtime.Serialization;
|
||||
using NitroxModel.DataStructures;
|
||||
|
||||
namespace NitroxModel_Subnautica.DataStructures.GameLogic
|
||||
{
|
||||
[Serializable]
|
||||
[DataContract]
|
||||
public class CyclopsFireData
|
||||
{
|
||||
[DataMember(Order = 1)]
|
||||
public NitroxId FireId { get; set; }
|
||||
|
||||
[DataMember(Order = 2)]
|
||||
public NitroxId CyclopsId { get; set; }
|
||||
|
||||
[DataMember(Order = 3)]
|
||||
public CyclopsRooms Room { get; set; }
|
||||
|
||||
[DataMember(Order = 4)]
|
||||
public int NodeIndex { get; set; }
|
||||
|
||||
protected CyclopsFireData()
|
||||
{
|
||||
// Constructor for serialization. Has to be "protected" for json serialization.
|
||||
}
|
||||
|
||||
public CyclopsFireData(NitroxId fireId, NitroxId cyclopsId, CyclopsRooms room, int nodeIndex)
|
||||
{
|
||||
FireId = fireId;
|
||||
CyclopsId = cyclopsId;
|
||||
Room = room;
|
||||
NodeIndex = nodeIndex;
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return $"[CyclopsFireData - FireId: {FireId}, CyclopsId: {CyclopsId}, Room: {Room}, FireNodeIndex: {NodeIndex}]";
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,67 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using LitJson;
|
||||
using NitroxModel.DataStructures.GameLogic.Entities;
|
||||
using NitroxModel.Helper;
|
||||
using static LootDistributionData;
|
||||
|
||||
namespace NitroxModel_Subnautica.DataStructures.GameLogic.Entities;
|
||||
|
||||
public class SubnauticaUwePrefabFactory : IUwePrefabFactory
|
||||
{
|
||||
private readonly LootDistributionData lootDistributionData;
|
||||
private readonly Dictionary<string, List<UwePrefab>> cache = new();
|
||||
|
||||
public SubnauticaUwePrefabFactory(string lootDistributionJson)
|
||||
{
|
||||
lootDistributionData = GetLootDistributionData(lootDistributionJson);
|
||||
}
|
||||
|
||||
public bool TryGetPossiblePrefabs(string biome, out List<UwePrefab> prefabs)
|
||||
{
|
||||
if (biome == null)
|
||||
{
|
||||
prefabs = null;
|
||||
return false;
|
||||
}
|
||||
if (cache.TryGetValue(biome, out prefabs))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
prefabs = new();
|
||||
BiomeType biomeType = (BiomeType)Enum.Parse(typeof(BiomeType), biome);
|
||||
if (lootDistributionData.GetBiomeLoot(biomeType, out DstData dstData))
|
||||
{
|
||||
foreach (PrefabData prefabData in dstData.prefabs)
|
||||
{
|
||||
if (lootDistributionData.srcDistribution.TryGetValue(prefabData.classId, out SrcData srcData))
|
||||
{
|
||||
// Manually went through the list of those to make this "filter"
|
||||
// You can verify this by looping through all of SrcData (e.g in LootDistributionData.Initialize)
|
||||
// print the prefabPath and check the TechType related to the provided classId (WorldEntityDatabase.TryGetInfo) with PDAScanner.IsFragment
|
||||
bool isFragment = srcData.prefabPath.Contains("Fragment") || srcData.prefabPath.Contains("BaseGlassDome");
|
||||
prefabs.Add(new(prefabData.classId, prefabData.count, prefabData.probability, isFragment));
|
||||
}
|
||||
}
|
||||
}
|
||||
cache[biome] = prefabs;
|
||||
return true;
|
||||
}
|
||||
|
||||
private LootDistributionData GetLootDistributionData(string lootDistributionJson)
|
||||
{
|
||||
// LitJson uses the computer's local CultureInfo when parsing the JSON files.
|
||||
// However, these json files were saved in en_US. Ensure that this is done for the current thread.
|
||||
CultureManager.ConfigureCultureInfo();
|
||||
|
||||
JsonMapper.RegisterImporter((double value) => Convert.ToSingle(value));
|
||||
|
||||
Dictionary<string, LootDistributionData.SrcData> result = JsonMapper.ToObject<Dictionary<string, LootDistributionData.SrcData>>(lootDistributionJson);
|
||||
|
||||
LootDistributionData lootDistributionData = new LootDistributionData();
|
||||
lootDistributionData.Initialize(result);
|
||||
|
||||
return lootDistributionData;
|
||||
}
|
||||
}
|
@@ -0,0 +1,32 @@
|
||||
using System.Collections.Generic;
|
||||
using NitroxModel.DataStructures.GameLogic.Entities;
|
||||
using UWE;
|
||||
|
||||
namespace NitroxModel_Subnautica.DataStructures.GameLogic.Entities;
|
||||
|
||||
public class SubnauticaUweWorldEntityFactory : IUweWorldEntityFactory
|
||||
{
|
||||
private readonly Dictionary<string, WorldEntityInfo> worldEntitiesByClassId;
|
||||
|
||||
public SubnauticaUweWorldEntityFactory(Dictionary<string, WorldEntityInfo> worldEntitiesByClassId)
|
||||
{
|
||||
this.worldEntitiesByClassId = worldEntitiesByClassId;
|
||||
}
|
||||
|
||||
public bool TryFind(string classId, out UweWorldEntity uweWorldEntity)
|
||||
{
|
||||
if (worldEntitiesByClassId.TryGetValue(classId, out WorldEntityInfo worldEntityInfo))
|
||||
{
|
||||
uweWorldEntity = new(worldEntityInfo.classId,
|
||||
worldEntityInfo.techType.ToDto(),
|
||||
worldEntityInfo.slotType.ToString(),
|
||||
worldEntityInfo.prefabZUp,
|
||||
(int)worldEntityInfo.cellLevel,
|
||||
worldEntityInfo.localScale.ToDto());
|
||||
|
||||
return true;
|
||||
}
|
||||
uweWorldEntity = null;
|
||||
return false;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user