Combat & Visibility & Collisions
Converted entity materials to new fade shader Implemented visibility system Refactored per-instance entity code to run inside monobehavior on entity instances Created state machine AI for enemy ships with basic patrol and combat routines Removed legacy AI code (controller item behaviors) Added automatic trigger group assignment for matched weapons Created ship collision system Created shield VFX and colliders
This commit is contained in:
parent
8d4bd04891
commit
b53e4aec8c
204 changed files with 8182 additions and 1919 deletions
42
Assets/Scripts/ServerShared/Agents/Tasks/AgentTask.cs
Normal file
42
Assets/Scripts/ServerShared/Agents/Tasks/AgentTask.cs
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using JsonKnownTypes;
|
||||
using MessagePack;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
[MessagePackObject,
|
||||
Union(0, typeof(StationTowing)),
|
||||
Union(1, typeof(Mining)),
|
||||
Union(2, typeof(Survey)),
|
||||
Union(3, typeof(HaulingTask)),
|
||||
JsonObject(MemberSerialization.OptIn), JsonConverter(typeof(JsonKnownTypesConverter<DatabaseEntry>))]
|
||||
public abstract class AgentTask : DatabaseEntry
|
||||
{
|
||||
[JsonProperty("priority"), Key(1)]
|
||||
public int Priority;
|
||||
|
||||
[JsonProperty("zone"), Key(2)]
|
||||
public Guid Zone;
|
||||
|
||||
[JsonProperty("reserved"), Key(3)]
|
||||
public bool Reserved;
|
||||
|
||||
[IgnoreMember] public abstract TaskType Type { get; }
|
||||
}
|
||||
|
||||
public enum TaskType
|
||||
{
|
||||
None,
|
||||
Mine,
|
||||
Haul,
|
||||
Tow,
|
||||
Defend,
|
||||
Attack,
|
||||
Explore
|
||||
}
|
||||
|
||||
11
Assets/Scripts/ServerShared/Agents/Tasks/AgentTask.cs.meta
Normal file
11
Assets/Scripts/ServerShared/Agents/Tasks/AgentTask.cs.meta
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 610ba26a0be594144b79c6206a0623ff
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
26
Assets/Scripts/ServerShared/Agents/Tasks/HaulingTask.cs
Normal file
26
Assets/Scripts/ServerShared/Agents/Tasks/HaulingTask.cs
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using MessagePack;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
public class HaulingTask : AgentTask
|
||||
{
|
||||
public override TaskType Type => TaskType.Haul;
|
||||
|
||||
[JsonProperty("origin"), Key(4)]
|
||||
public Entity Origin;
|
||||
|
||||
[JsonProperty("target"), Key(5)]
|
||||
public Entity Target;
|
||||
|
||||
[JsonProperty("itemType"), Key(6)]
|
||||
public Guid ItemType;
|
||||
|
||||
[JsonProperty("quantity"), Key(7)]
|
||||
public int Quantity;
|
||||
}
|
||||
11
Assets/Scripts/ServerShared/Agents/Tasks/HaulingTask.cs.meta
Normal file
11
Assets/Scripts/ServerShared/Agents/Tasks/HaulingTask.cs.meta
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 167d373f6e5692b4ab939e83c26b7b57
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
20
Assets/Scripts/ServerShared/Agents/Tasks/Mining.cs
Normal file
20
Assets/Scripts/ServerShared/Agents/Tasks/Mining.cs
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using JsonKnownTypes;
|
||||
using MessagePack;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
[MessagePackObject,
|
||||
JsonObject(MemberSerialization.OptIn), JsonConverter(typeof(JsonKnownTypesConverter<DatabaseEntry>))]
|
||||
public class Mining : AgentTask
|
||||
{
|
||||
[IgnoreMember] public override TaskType Type => TaskType.Mine;
|
||||
|
||||
[JsonProperty("asteroids"), Key(4)]
|
||||
public Guid Asteroids;
|
||||
}
|
||||
11
Assets/Scripts/ServerShared/Agents/Tasks/Mining.cs.meta
Normal file
11
Assets/Scripts/ServerShared/Agents/Tasks/Mining.cs.meta
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 6e4409ff5e14e06468f205574cc67a3c
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
31
Assets/Scripts/ServerShared/Agents/Tasks/PatrolOrbits.cs
Normal file
31
Assets/Scripts/ServerShared/Agents/Tasks/PatrolOrbits.cs
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
using System;
|
||||
|
||||
public class PatrolOrbitsTask : AgentTask
|
||||
{
|
||||
public override TaskType Type => TaskType.Defend;
|
||||
public Guid[] Circuit;
|
||||
}
|
||||
|
||||
public class PatrolOrbitsState : BaseState
|
||||
{
|
||||
public PatrolOrbitsTask Task;
|
||||
public Guid CurrentTarget
|
||||
{
|
||||
get => Task.Circuit[_currentTargetIndex];
|
||||
}
|
||||
private int _currentTargetIndex;
|
||||
public void NextTarget()
|
||||
{
|
||||
_currentTargetIndex++;
|
||||
_currentTargetIndex %= Task.Circuit.Length;
|
||||
}
|
||||
|
||||
public PatrolOrbitsState(Agent agent) : base(agent)
|
||||
{
|
||||
var patrolMoveState = new MoveToOrbitState(agent);
|
||||
Transitions.Add(new StateTransition(patrolMoveState,
|
||||
() => true,
|
||||
() => patrolMoveState.Orbit = CurrentTarget));
|
||||
patrolMoveState.Transitions.Add(new StateTransition(this, () => patrolMoveState.Distance < 10, NextTarget));
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
fileFormatVersion: 2
|
||||
guid: dcfc94fde9bb4aa2ac3c7d88180689cb
|
||||
timeCreated: 1613182188
|
||||
26
Assets/Scripts/ServerShared/Agents/Tasks/StationTowing.cs
Normal file
26
Assets/Scripts/ServerShared/Agents/Tasks/StationTowing.cs
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using JsonKnownTypes;
|
||||
using MessagePack;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
[MessagePackObject,
|
||||
JsonObject(MemberSerialization.OptIn), JsonConverter(typeof(JsonKnownTypesConverter<DatabaseEntry>))]
|
||||
public class StationTowing : AgentTask
|
||||
{
|
||||
[IgnoreMember] public override TaskType Type => TaskType.Tow;
|
||||
|
||||
[JsonProperty("station"), Key(4)]
|
||||
public OrbitalEntity Station;
|
||||
|
||||
[JsonProperty("orbitParent"), Key(5)]
|
||||
public Guid OrbitParent;
|
||||
|
||||
[JsonProperty("orbitDistance"), Key(6)]
|
||||
public float OrbitDistance;
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: c8845fb5e89a4bf46abdf94517139172
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
20
Assets/Scripts/ServerShared/Agents/Tasks/Survey.cs
Normal file
20
Assets/Scripts/ServerShared/Agents/Tasks/Survey.cs
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using JsonKnownTypes;
|
||||
using MessagePack;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
[MessagePackObject,
|
||||
JsonObject(MemberSerialization.OptIn), JsonConverter(typeof(JsonKnownTypesConverter<DatabaseEntry>))]
|
||||
public class Survey : AgentTask
|
||||
{
|
||||
[IgnoreMember] public override TaskType Type => TaskType.Explore;
|
||||
|
||||
[JsonProperty("station"), Key(4)]
|
||||
public List<Guid> Planets;
|
||||
}
|
||||
11
Assets/Scripts/ServerShared/Agents/Tasks/Survey.cs.meta
Normal file
11
Assets/Scripts/ServerShared/Agents/Tasks/Survey.cs.meta
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: f7e87dcf21f32dd49907439f53f7e5e7
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
8
Assets/Scripts/ServerShared/Agents/Tasks/WanderTask.cs
Normal file
8
Assets/Scripts/ServerShared/Agents/Tasks/WanderTask.cs
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
public class WanderTask : AgentTask
|
||||
{
|
||||
public override TaskType Type => TaskType.None;
|
||||
}
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 2320c5e3a86f42eeacb133b6529bfe89
|
||||
timeCreated: 1607467429
|
||||
Loading…
Reference in a new issue