Demo Hotfixes
Replaced Unity TAA with PlayDead TAA Custom keyboard layout test scene Adjusted Aetheric Drive VFX to be more subtle Reworked stardust VFX to reduce flickering artifacts Added Action Bar & weapon groups saving/loading Implemented security levels and faction safe zone visualization Improved station placement (now include defensive turrets)
This commit is contained in:
parent
eb64cbf94a
commit
2c4520000b
128 changed files with 12821 additions and 561 deletions
|
|
@ -33,9 +33,9 @@ public class CombatState : BaseState
|
|||
|
||||
var toTarget = target.Position - _agent.Ship.Position;
|
||||
var targetDistance = length(toTarget);
|
||||
for (var i = 0; i < _agent.Ship.TriggerGroups.Length; i++)
|
||||
for (var i = 0; i < _agent.Ship.WeaponGroups.Length; i++)
|
||||
{
|
||||
var group = _agent.Ship.TriggerGroups[i];
|
||||
var group = _agent.Ship.WeaponGroups[i];
|
||||
var dps = 0f;
|
||||
foreach (var weapon in group.weapons)
|
||||
if (weapon.Item.Online.Value &&
|
||||
|
|
@ -80,7 +80,7 @@ public class CombatState : BaseState
|
|||
|
||||
if (selectedGroup >= 0)
|
||||
{
|
||||
var testWeapon = _agent.Ship.TriggerGroups[selectedGroup].weapons.First();
|
||||
var testWeapon = _agent.Ship.WeaponGroups[selectedGroup].weapons.First();
|
||||
if(testWeapon.Velocity > 1)
|
||||
{
|
||||
var targetHullData = _agent.ItemManager.GetData(target.Hull) as HullData;
|
||||
|
|
@ -100,7 +100,7 @@ public class CombatState : BaseState
|
|||
var shouldFire = dot(
|
||||
_agent.Ship.HardpointTransforms[_agent.Ship.Hardpoints[testWeapon.Item.Position.x, testWeapon.Item.Position.y]].direction,
|
||||
toTarget) > .99f;
|
||||
foreach (var weapon in _agent.Ship.TriggerGroups[selectedGroup].weapons)
|
||||
foreach (var weapon in _agent.Ship.WeaponGroups[selectedGroup].weapons)
|
||||
{
|
||||
if (shouldFire)
|
||||
weapon.Activate();
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ public abstract class Entity
|
|||
public readonly Dictionary<HardpointData, (float3 position, float3 direction)> HardpointTransforms =
|
||||
new Dictionary<HardpointData, (float3 position, float3 direction)>();
|
||||
|
||||
public readonly (List<Weapon> weapons, List<EquippedItem> items)[] TriggerGroups;
|
||||
public (List<Weapon> weapons, List<EquippedItem> items)[] WeaponGroups;
|
||||
|
||||
public List<IPopulationAssignment> PopulationAssignments = new List<IPopulationAssignment>();
|
||||
|
||||
|
|
@ -160,7 +160,8 @@ public abstract class Entity
|
|||
{
|
||||
if (Target.Value == remove.Value) Target.Value = null;
|
||||
}));
|
||||
GenerateTriggerGroups();
|
||||
if(WeaponGroups.All(wg=>!wg.items.Any()))
|
||||
GenerateWeaponGroups();
|
||||
}
|
||||
|
||||
public virtual void Deactivate()
|
||||
|
|
@ -183,9 +184,9 @@ public abstract class Entity
|
|||
HullData = itemManager.GetData(hull) as HullData;
|
||||
Name = HullData.Name;
|
||||
MapEntity();
|
||||
TriggerGroups = new (List<Weapon> triggers, List<EquippedItem> items)[itemManager.GameplaySettings.TriggerGroupCount];
|
||||
for(int i=0; i<itemManager.GameplaySettings.TriggerGroupCount; i++)
|
||||
TriggerGroups[i] = (new List<Weapon>(), new List<EquippedItem>());
|
||||
WeaponGroups = new (List<Weapon> weapons, List<EquippedItem> items)[itemManager.GameplaySettings.WeaponGroupCount];
|
||||
for(int i=0; i<itemManager.GameplaySettings.WeaponGroupCount; i++)
|
||||
WeaponGroups[i] = (new List<Weapon>(), new List<EquippedItem>());
|
||||
|
||||
ItemDestroyed = ItemDamage.Where(x => x.item.EquippableItem.Durability < .01f).Select(x=>x.item);
|
||||
WeaponDestroyed = ItemDestroyed.Select(x => x.Behaviors.FirstOrDefault(b => b is Weapon) as Weapon).Where(x => x != null);
|
||||
|
|
@ -297,15 +298,15 @@ public abstract class Entity
|
|||
GearOccupancy = new EquippedItem[hullData.Shape.Width, hullData.Shape.Height];
|
||||
}
|
||||
|
||||
public void GenerateTriggerGroups()
|
||||
public void GenerateWeaponGroups()
|
||||
{
|
||||
foreach (var group in Weapons
|
||||
.GroupBy(w => w.Item.EquippableItem.Data.LinkID)
|
||||
.OrderBy(wg=>wg.Average(w=>w.Range))
|
||||
.Select((weapons, index) => (weapons, index)))
|
||||
{
|
||||
TriggerGroups[group.index].weapons = group.weapons.ToList();
|
||||
TriggerGroups[group.index].items = group.weapons.Select(w=>w.Item).ToList();
|
||||
WeaponGroups[group.index].weapons = group.weapons.ToList();
|
||||
WeaponGroups[group.index].items = group.weapons.Select(w=>w.Item).ToList();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -13,7 +13,9 @@ public static class EntitySerializer
|
|||
if (entity is OrbitalEntity orbital)
|
||||
pack = new OrbitalEntityPack
|
||||
{
|
||||
Orbit = orbital.OrbitData
|
||||
Orbit = orbital.OrbitData,
|
||||
SecurityLevel = orbital.SecurityLevel,
|
||||
SecurityRadius = orbital.SecurityRadius
|
||||
};
|
||||
else if (entity is Ship ship)
|
||||
pack = new ShipPack
|
||||
|
|
@ -49,6 +51,7 @@ public static class EntitySerializer
|
|||
pack.Temperature = entity.Temperature;
|
||||
pack.Conductivity = entity.HullConductivity;
|
||||
pack.Children = entity.Children.Select(Pack).ToArray();
|
||||
pack.WeaponGroups = entity.WeaponGroups.Select(wg => wg.items.Select(item => entity.Equipment.IndexOf(item)).ToArray()).ToArray();
|
||||
return pack;
|
||||
}
|
||||
|
||||
|
|
@ -80,6 +83,8 @@ public static class EntitySerializer
|
|||
{
|
||||
var entity = new OrbitalEntity(itemManager, zone, instantiate ? (EquippableItem) itemManager.Instantiate(pack.Hull) : pack.Hull, pack.Orbit, pack.Settings);
|
||||
Restore(itemManager, zone, pack, entity, instantiate);
|
||||
entity.SecurityLevel = pack.SecurityLevel;
|
||||
entity.SecurityRadius = pack.SecurityRadius;
|
||||
return entity;
|
||||
}
|
||||
|
||||
|
|
@ -133,35 +138,37 @@ public static class EntitySerializer
|
|||
|
||||
foreach(var v in hullData.Shape.Coordinates)
|
||||
entity.HullConductivity[v.x,v.y] = pack.Conductivity[v.x,v.y];
|
||||
|
||||
entity.WeaponGroups = pack.WeaponGroups.Select(itemIndices =>
|
||||
{
|
||||
var items = itemIndices.Select(i => entity.Equipment[i]);
|
||||
return (items.Select(i => i.GetBehavior<Weapon>()).ToList(), items.ToList());
|
||||
}).ToArray();
|
||||
}
|
||||
}
|
||||
|
||||
[MessagePackObject]
|
||||
public class SavedStory
|
||||
{
|
||||
[Key(0)]
|
||||
public string StoryJson;
|
||||
|
||||
[Key(1)]
|
||||
public string StateJson;
|
||||
[Key(0)] public string StoryJson;
|
||||
[Key(1)] public string StateJson;
|
||||
}
|
||||
|
||||
[MessagePackObject]
|
||||
public class ShipPack : EntityPack
|
||||
{
|
||||
[Key(16)] public float3 Position;
|
||||
[Key(17)] public float2 Direction;
|
||||
[Key(18)] public bool IsPlayerShip;
|
||||
[Key(17)] public float3 Position;
|
||||
[Key(18)] public float2 Direction;
|
||||
[Key(19)] public bool IsPlayerShip;
|
||||
}
|
||||
|
||||
[MessagePackObject]
|
||||
public class OrbitalEntityPack : EntityPack
|
||||
{
|
||||
[Key(16)]
|
||||
public Guid Orbit;
|
||||
|
||||
[Key(17)]
|
||||
public SavedStory Story;
|
||||
[Key(17)] public Guid Orbit;
|
||||
[Key(18)] public SavedStory Story;
|
||||
[Key(19)] public SecurityLevel SecurityLevel;
|
||||
[Key(20)] public float SecurityRadius;
|
||||
}
|
||||
|
||||
[MessagePackObject,
|
||||
|
|
@ -169,50 +176,22 @@ public class OrbitalEntityPack : EntityPack
|
|||
Union(1, typeof(ShipPack))]
|
||||
public abstract class EntityPack
|
||||
{
|
||||
[Key(0)]
|
||||
public string Name;
|
||||
|
||||
[Key(1)]
|
||||
public EquippableItem Hull;
|
||||
|
||||
[Key(2)]
|
||||
public (int2 position, EquippableItem item)[] Equipment;
|
||||
|
||||
[Key(3)]
|
||||
public (int2 position, EquippableItem item)[] CargoBays;
|
||||
|
||||
[Key(4)]
|
||||
public (int2 position, EquippableItem item)[] DockingBays;
|
||||
|
||||
[Key(5)]
|
||||
public Dictionary<int2, PersistentBehaviorData[]> PersistedBehaviors;
|
||||
|
||||
[Key(6)]
|
||||
public float[,] Temperature;
|
||||
|
||||
[Key(7)]
|
||||
public float[,] Armor;
|
||||
|
||||
[Key(8)]
|
||||
public bool2[,] Conductivity;
|
||||
|
||||
[Key(10)]
|
||||
public int[] DockingBayAssignments;
|
||||
|
||||
[Key(11)]
|
||||
public (int2 position, ItemInstance item)[][] CargoContents;
|
||||
|
||||
[Key(12)]
|
||||
public (int2 position, ItemInstance item)[][] DockingBayContents;
|
||||
|
||||
[Key(13)]
|
||||
public EntityPack[] Children;
|
||||
|
||||
[Key(14)]
|
||||
public EntitySettings Settings;
|
||||
|
||||
[Key(15)]
|
||||
public Guid Faction;
|
||||
[Key(0)] public string Name;
|
||||
[Key(1)] public EquippableItem Hull;
|
||||
[Key(2)] public (int2 position, EquippableItem item)[] Equipment;
|
||||
[Key(3)] public (int2 position, EquippableItem item)[] CargoBays;
|
||||
[Key(4)] public (int2 position, EquippableItem item)[] DockingBays;
|
||||
[Key(5)] public Dictionary<int2, PersistentBehaviorData[]> PersistedBehaviors;
|
||||
[Key(6)] public float[,] Temperature;
|
||||
[Key(7)] public float[,] Armor;
|
||||
[Key(8)] public bool2[,] Conductivity;
|
||||
[Key(10)] public int[] DockingBayAssignments;
|
||||
[Key(11)] public (int2 position, ItemInstance item)[][] CargoContents;
|
||||
[Key(12)] public (int2 position, ItemInstance item)[][] DockingBayContents;
|
||||
[Key(13)] public EntityPack[] Children;
|
||||
[Key(14)] public EntitySettings Settings;
|
||||
[Key(15)] public Guid Faction;
|
||||
[Key(16)] public int[][] WeaponGroups;
|
||||
|
||||
private int _price;
|
||||
|
||||
|
|
|
|||
|
|
@ -165,6 +165,22 @@ public enum CompoundCommodityCategory
|
|||
Assemblies = 5
|
||||
}
|
||||
|
||||
public enum FactionRelationship
|
||||
{
|
||||
Hated = 0, // Kill on sight
|
||||
Hostile = 1, // Can enter open areas
|
||||
Neutral = 2, // Can dock in open areas, enter secure areas
|
||||
Friendly = 3, // Can dock in secure areas, enter critical areas
|
||||
Beloved = 4 // Cah dock even in critical areas
|
||||
}
|
||||
|
||||
public enum SecurityLevel
|
||||
{
|
||||
Open = 0,
|
||||
Secure = 1,
|
||||
Critical = 2
|
||||
}
|
||||
|
||||
public enum TemperatureUnit
|
||||
{
|
||||
Kelvin,
|
||||
|
|
|
|||
|
|
@ -55,16 +55,16 @@ public class LoadoutGenerator
|
|||
return EntitySerializer.Pack(entity);
|
||||
}
|
||||
|
||||
public EntityPack GenerateTurretLoadout()
|
||||
public OrbitalEntityPack GenerateTurretLoadout()
|
||||
{
|
||||
var hull = ItemManager.CreateInstance(RandomHull(HullType.Turret)) as EquippableItem;
|
||||
var entity = new OrbitalEntity(ItemManager, null, hull, Guid.Empty, ItemManager.GameplaySettings.DefaultEntitySettings);
|
||||
entity.Faction = Faction;
|
||||
OutfitEntity(entity);
|
||||
return EntitySerializer.Pack(entity);
|
||||
return EntitySerializer.Pack(entity) as OrbitalEntityPack;
|
||||
}
|
||||
|
||||
public EntityPack GenerateStationLoadout()
|
||||
public OrbitalEntityPack GenerateStationLoadout()
|
||||
{
|
||||
var hullData = RandomHull(HullType.Station);
|
||||
var hull = ItemManager.CreateInstance(hullData) as EquippableItem;
|
||||
|
|
@ -96,7 +96,7 @@ public class LoadoutGenerator
|
|||
cargo.TryStore(instance);
|
||||
}
|
||||
|
||||
return EntitySerializer.Pack(entity);
|
||||
return EntitySerializer.Pack(entity) as OrbitalEntityPack;
|
||||
}
|
||||
|
||||
public HullData RandomHull(HullType type, Predicate<HullData> hullFilter = null)
|
||||
|
|
|
|||
|
|
@ -12,6 +12,8 @@ using float2 = Unity.Mathematics.float2;
|
|||
public class OrbitalEntity : Entity
|
||||
{
|
||||
public Guid OrbitData;
|
||||
public SecurityLevel SecurityLevel;
|
||||
public float SecurityRadius;
|
||||
|
||||
public OrbitalEntity(ItemManager itemManager, Zone zone, EquippableItem hull, Guid orbit, EntitySettings settings) : base(itemManager, zone, hull, settings)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -43,6 +43,9 @@ public class SavedGame
|
|||
|
||||
[Key(11)]
|
||||
public bool IsTutorial;
|
||||
|
||||
[Key(12)]
|
||||
public FactionRelationship[] Relationships;
|
||||
|
||||
public SavedGame() { }
|
||||
|
||||
|
|
@ -51,6 +54,7 @@ public class SavedGame
|
|||
DiscoveredZones = sector.DiscoveredZones.Select(dz => Array.IndexOf(sector.Zones, dz)).ToArray();
|
||||
Background = sector.Background;
|
||||
Factions = sector.HomeZones.Keys.Select(f => f.ID).ToArray();
|
||||
Relationships = sector.Factions.Select(f => sector.FactionRelationships[f]).ToArray();
|
||||
|
||||
HomeZones = sector.HomeZones.ToDictionary(
|
||||
x => Array.IndexOf(Factions, x.Key.ID),
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@ public class Sector
|
|||
public SectorZone[] Zones { get; }
|
||||
public SectorZone Entrance { get; }
|
||||
public SectorZone Exit { get; }
|
||||
public Dictionary<Faction, FactionRelationship> FactionRelationships { get; } = new Dictionary<Faction, FactionRelationship>();
|
||||
|
||||
private HashSet<Guid> _containedFactions;
|
||||
private SectorZone[] _exitPath;
|
||||
|
|
@ -42,7 +43,13 @@ public class Sector
|
|||
public Sector(CultCache cultCache, SavedGame savedGame)
|
||||
{
|
||||
Background = savedGame.Background;
|
||||
|
||||
Factions = savedGame.Factions.Select(cultCache.Get<Faction>).ToArray();
|
||||
for (var i = 0; i < Factions.Length; i++)
|
||||
{
|
||||
FactionRelationships[Factions[i]] = savedGame.Relationships[i];
|
||||
}
|
||||
|
||||
Zones = savedGame.Zones.Select(zone =>
|
||||
{
|
||||
return new SectorZone
|
||||
|
|
@ -87,6 +94,7 @@ public class Sector
|
|||
var factions = cache.GetAll<Faction>();
|
||||
var random = new Random(seed == 0 ? (uint) (DateTime.Now.Ticks % uint.MaxValue) : seed);
|
||||
Factions = factions.OrderBy(x => random.NextFloat()).Take(settings.MegaCount).ToArray();
|
||||
foreach (var f in Factions) FactionRelationships[f] = FactionRelationship.Neutral;
|
||||
|
||||
Zones = GenerateZones(settings.ZoneCount, ref random, progressCallback);
|
||||
|
||||
|
|
@ -148,7 +156,11 @@ public class Sector
|
|||
factions.AddRange(neutralFactions);
|
||||
|
||||
Factions = factions.ToArray();
|
||||
foreach (var faction in Factions) faction.InfluenceDistance = (faction.InfluenceDistance + 1) / 2;
|
||||
foreach (var faction in Factions)
|
||||
{
|
||||
FactionRelationships[faction] = FactionRelationship.Neutral;
|
||||
faction.InfluenceDistance = (faction.InfluenceDistance + 1) / 2;
|
||||
}
|
||||
|
||||
Zones = GenerateZones(settings.ZoneCount, ref random, progressCallback);
|
||||
|
||||
|
|
@ -186,8 +198,13 @@ public class Sector
|
|||
|
||||
var potentialQuestZones = Zones
|
||||
.Where(z => z.Factions.Contains(antagonistFaction) && z.Factions.Contains(bufferFaction));
|
||||
HomeZones[questFaction] = potentialQuestZones
|
||||
.MaxBy(z=>z.Distance[HomeZones[antagonistFaction]] * ConnectedRegion(z, questFaction.InfluenceDistance).Count);
|
||||
if (potentialQuestZones.Any())
|
||||
HomeZones[questFaction] = potentialQuestZones
|
||||
.MaxBy(z => z.Distance[HomeZones[antagonistFaction]] * ConnectedRegion(z, questFaction.InfluenceDistance).Count);
|
||||
else
|
||||
HomeZones[questFaction] = Zones
|
||||
.Where(z => z.Factions.Contains(antagonistFaction))
|
||||
.MinBy(z=>z.Distance[HomeZones[bufferFaction]]);
|
||||
|
||||
CalculateFactionInfluence(progressCallback);
|
||||
|
||||
|
|
|
|||
|
|
@ -172,7 +172,7 @@ public class GameplaySettings
|
|||
public float WormholeExitCurveStart = .8f;
|
||||
public float ThermalWearExponent = .01f;
|
||||
public float QualityWearExponent = 2;
|
||||
public int TriggerGroupCount = 6;
|
||||
public int WeaponGroupCount = 6;
|
||||
public float WarpDistance = 25;
|
||||
public float DockingDistance = 25;
|
||||
public float ProductionPersonalityLerp = .05f;
|
||||
|
|
|
|||
|
|
@ -225,20 +225,73 @@ public static class ZoneGenerator
|
|||
var nearestFaction = sector.Factions.MinBy(f => sector.HomeZones[f].Distance[sectorZone]);
|
||||
var nearestFactionHomeZone = sector.HomeZones[nearestFaction];
|
||||
var factionPresence = nearestFaction.InfluenceDistance - nearestFactionHomeZone.Distance[sectorZone] + 1;
|
||||
|
||||
var stationCount = (int)(random.NextFloat() * (factionPresence + 1));
|
||||
var potentialLagrangePoints = planets
|
||||
.Where(p => p.Parent != null && p.Parent.Children
|
||||
.TrueForAll(c => !(c != p && abs(c.Distance - p.Distance) < .1f))) // Filter Rosettes
|
||||
.OrderBy(p => p.Distance)
|
||||
.ToArray();
|
||||
// Pick a selection from the middle of the distribution
|
||||
var selectedStationOrbits = potentialLagrangePoints
|
||||
.Skip(potentialLagrangePoints.Length / 2)
|
||||
.Take(stationCount)
|
||||
.Select(p=>orbitMap[p])
|
||||
.ToArray();
|
||||
|
||||
var loadoutGenerator = isTutorial ? new LoadoutGenerator(ref random, itemManager, nearestFaction, .5f) :
|
||||
new LoadoutGenerator(ref random, itemManager, sector, sectorZone, nearestFaction, .5f);
|
||||
for (int i = 0; i < factionPresence; i++)
|
||||
|
||||
foreach (var orbit in selectedStationOrbits)
|
||||
{
|
||||
var security = (SecurityLevel) ((int) ((1f - pow(random.NextFloat(), factionPresence / 2f)) * 3f));
|
||||
var lagrangeOrbit = new OrbitData
|
||||
{
|
||||
ID = Guid.NewGuid(),
|
||||
Parent = orbit.Parent,
|
||||
Distance = new ReactiveProperty<float>(orbit.Distance.Value),
|
||||
Phase = orbit.Phase + PI / 3 * sign(random.NextFloat() - .5f)
|
||||
};
|
||||
pack.Orbits.Add(lagrangeOrbit);
|
||||
|
||||
var station = loadoutGenerator.GenerateStationLoadout();
|
||||
station.Orbit = lagrangeOrbit.ID;
|
||||
station.SecurityLevel = security;
|
||||
station.SecurityRadius = pack.Radius * .75f;
|
||||
pack.Entities.Add(station);
|
||||
|
||||
var turretPhase = 20f / lagrangeOrbit.Distance.Value;
|
||||
|
||||
var leadingTurretOrbit = new OrbitData
|
||||
{
|
||||
ID = Guid.NewGuid(),
|
||||
Parent = orbit.Parent,
|
||||
Distance = new ReactiveProperty<float>(orbit.Distance.Value),
|
||||
Phase = lagrangeOrbit.Phase + turretPhase
|
||||
};
|
||||
pack.Orbits.Add(leadingTurretOrbit);
|
||||
var leadingTurret = loadoutGenerator.GenerateTurretLoadout();
|
||||
leadingTurret.Orbit = leadingTurretOrbit.ID;
|
||||
pack.Entities.Add(leadingTurret);
|
||||
|
||||
var trailingTurretOrbit = new OrbitData
|
||||
{
|
||||
ID = Guid.NewGuid(),
|
||||
Parent = orbit.Parent,
|
||||
Distance = new ReactiveProperty<float>(orbit.Distance.Value),
|
||||
Phase = lagrangeOrbit.Phase - turretPhase
|
||||
};
|
||||
pack.Orbits.Add(trailingTurretOrbit);
|
||||
var trailingTurret = loadoutGenerator.GenerateTurretLoadout();
|
||||
trailingTurret.Orbit = trailingTurretOrbit.ID;
|
||||
pack.Entities.Add(trailingTurret);
|
||||
}
|
||||
|
||||
var enemyCount = (int)(random.NextFloat() * factionPresence * 2) + stationCount;
|
||||
for (int i = 0; i < enemyCount; i++)
|
||||
{
|
||||
pack.Entities.Add(loadoutGenerator.GenerateShipLoadout());
|
||||
}
|
||||
|
||||
var replacePlanet = pack.Planets.MinBy(p => p.Mass.Value);
|
||||
pack.Planets.Remove(replacePlanet);
|
||||
var stationOrbit = replacePlanet.Orbit;
|
||||
var station = loadoutGenerator.GenerateStationLoadout();
|
||||
((OrbitalEntityPack) station).Orbit = stationOrbit;
|
||||
pack.Entities.Add(station);
|
||||
|
||||
return pack;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue