diff --git a/Core/Game/Abilities/Ability.cs b/Core/Game/Abilities/Ability.cs index 1c95b98d..a0113691 100644 --- a/Core/Game/Abilities/Ability.cs +++ b/Core/Game/Abilities/Ability.cs @@ -64,9 +64,7 @@ protected set } } } - - - + internal void Setup(LSAgent agent, int id) { System.Type mainType = this.GetType(); diff --git a/Core/Game/Abilities/Essential/Move.cs b/Core/Game/Abilities/Essential/Move.cs index fcf3be27..aeaf7bd2 100644 --- a/Core/Game/Abilities/Essential/Move.cs +++ b/Core/Game/Abilities/Essential/Move.cs @@ -6,7 +6,7 @@ namespace Lockstep public class Move : ActiveAbility { public const long FormationStop = FixedMath.One / 8; - public const long GroupDirectStop = FixedMath.One / 2; + public const long GroupDirectStop = FixedMath.One; public const long DirectStop = FixedMath.One / 8; private const int MinimumOtherStopTime = (int)(LockstepManager.FrameRate / 4); private const int repathRate = (int)LockstepManager.FrameRate * 4 / 4; @@ -69,6 +69,8 @@ private int StraightRepathRate //Called when unit arrives at destination public event Action onArrive; + public event Action onStartMove; + //Called whenever movement is stopped... i.e. to attack public event Action OnStopMove; @@ -104,6 +106,12 @@ public long timescaledSpeed private long closingDistance; private long stuckTolerance; + [Lockstep (true)] + public bool SlowArrival { + get; + set; + } + #region Serialized [SerializeField] @@ -142,6 +150,7 @@ protected override void OnSetup() stuckTolerance = ((Agent.Body.Radius * Speed) >> FixedMath.SHIFT_AMOUNT) / LockstepManager.FrameRate; stuckTolerance *= stuckTolerance; CanPathfind = _canPathfind; + this.SlowArrival = true; } protected override void OnInitialize() @@ -305,7 +314,12 @@ protected override void OnSimulate() Arrive(); return; } - desiredVelocity = (movementDirection * (distance) / (closingDistance)); + if (this.SlowArrival) { + desiredVelocity = (movementDirection * (distance) / (closingDistance)); + } + else { + desiredVelocity = (movementDirection); + } } @@ -335,6 +349,7 @@ protected override void OnSimulate() protected override void OnExecute(Command com) { + if (com.ContainsData ()) { Agent.StopCast(ID); @@ -439,6 +454,8 @@ public void StartMove(Vector2d destination) IsCasting = true; stuckTick = 0; forcePathfind = false; + if (onStartMove != null) + onStartMove (); } } diff --git a/Core/Game/Agents/Visuals/Materials/Hex.mat b/Core/Game/Agents/Visuals/Materials/Hex.mat index a182b187..67af3ada 100644 --- a/Core/Game/Agents/Visuals/Materials/Hex.mat +++ b/Core/Game/Agents/Visuals/Materials/Hex.mat @@ -8,11 +8,11 @@ Material: m_PrefabInternal: {fileID: 0} m_Name: Hex m_Shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0} - m_ShaderKeywords: _ALPHABLEND_ON + m_ShaderKeywords: _ALPHATEST_ON m_LightmapFlags: 5 - m_CustomRenderQueue: 3000 + m_CustomRenderQueue: 2450 stringTagMap: - RenderType: Transparent + RenderType: TransparentCutout m_SavedProperties: serializedVersion: 2 m_TexEnvs: @@ -83,11 +83,11 @@ Material: data: first: name: _SrcBlend - second: 5 + second: 1 data: first: name: _DstBlend - second: 10 + second: 0 data: first: name: _Cutoff @@ -99,7 +99,7 @@ Material: data: first: name: _ZWrite - second: 0 + second: 1 data: first: name: _Glossiness @@ -123,7 +123,7 @@ Material: data: first: name: _Mode - second: 2 + second: 1 data: first: name: _Metallic diff --git a/Core/Game/Agents/Visuals/Textures/Circle.png b/Core/Game/Agents/Visuals/Textures/Circle.png index f4709823..5b8358e9 100755 Binary files a/Core/Game/Agents/Visuals/Textures/Circle.png and b/Core/Game/Agents/Visuals/Textures/Circle.png differ diff --git a/Core/Game/Agents/Visuals/Textures/Circle.png.meta b/Core/Game/Agents/Visuals/Textures/Circle.png.meta index f8503522..90a40f6d 100644 --- a/Core/Game/Agents/Visuals/Textures/Circle.png.meta +++ b/Core/Game/Agents/Visuals/Textures/Circle.png.meta @@ -24,7 +24,7 @@ TextureImporter: cubemapConvolutionSteps: 7 cubemapConvolutionExponent: 1.5 seamlessCubemap: 0 - textureFormat: -1 + textureFormat: 4 maxTextureSize: 1024 textureSettings: filterMode: -1 diff --git a/Core/Game/Player/Commands/Command.cs b/Core/Game/Player/Commands/Command.cs index ed386840..33c74643 100644 --- a/Core/Game/Player/Commands/Command.cs +++ b/Core/Game/Player/Commands/Command.cs @@ -1,6 +1,8 @@ using System; using System.Collections.Generic; using UnityEngine; +using System.Linq; +using System.Reflection; namespace Lockstep { public partial class Command @@ -21,22 +23,33 @@ public static void Setup () { private static BiDictionary RegisteredData = new BiDictionary(); static void RegisterDefaults () { - Register (); + /*Register (); Register (); Register (); Register (); Register (); Register(); + Register ();*/ + foreach (Type t in Assembly.GetCallingAssembly().GetTypes()) + { + if (t.GetInterface("ICommandData") != null) + { + Register (t); + } + } } - public static void Register() where TData : ICommandData + private static void Register() where TData : ICommandData { + Register (typeof(TData)); + } + private static void Register (Type t) { if (RegisterCount > ushort.MaxValue) { throw new System.Exception(string.Format("Cannot register more than {0} types of data.", ushort.MaxValue + 1)); } - if (RegisteredData.ContainsKey(typeof(TData))) return; - RegisteredData.Add(typeof(TData), RegisterCount++); + if (RegisteredData.ContainsKey(t)) return; + RegisteredData.Add(t, RegisterCount++); } public byte ControllerID; diff --git a/Core/Game/Player/Commands/Default/EmptyData.cs b/Core/Game/Player/Commands/Default/EmptyData.cs new file mode 100644 index 00000000..fb2dca0b --- /dev/null +++ b/Core/Game/Player/Commands/Default/EmptyData.cs @@ -0,0 +1,15 @@ +using UnityEngine; +using System.Collections; +using Lockstep.Data; +namespace Lockstep +{ + public struct EmptyData : ICommandData + { + public void Read (Reader reader) { + + } + public void Write (Writer writer) { + + } + } +} \ No newline at end of file diff --git a/Core/Game/Player/Commands/Default/EmptyData.cs.meta b/Core/Game/Player/Commands/Default/EmptyData.cs.meta new file mode 100644 index 00000000..fbdf89ca --- /dev/null +++ b/Core/Game/Player/Commands/Default/EmptyData.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: d7c4de017b366416db8ea6295734e19f +timeCreated: 1457988007 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Core/Game/Player/RTSInterfacing.cs b/Core/Game/Player/RTSInterfacing.cs index 57c09aed..929bac93 100644 --- a/Core/Game/Player/RTSInterfacing.cs +++ b/Core/Game/Player/RTSInterfacing.cs @@ -56,9 +56,7 @@ public static LSAgent GetScreenAgent (Vector2 screenPos, Func con public static void Visualize () { - if (EventSystem.current.IsPointerOverGameObject()) { - return; - } + if (mainCamera .IsNotNull ()) { CachedRay = mainCamera.ScreenPointToRay (Input.mousePosition); CachedDidHit = NDRaycast.Raycast (CachedRay, out CachedHit); diff --git a/Core/Game/Player/RTSInterfacingHelper.cs b/Core/Game/Player/RTSInterfacingHelper.cs index 3556dbe2..8d4a1704 100644 --- a/Core/Game/Player/RTSInterfacingHelper.cs +++ b/Core/Game/Player/RTSInterfacingHelper.cs @@ -103,12 +103,12 @@ protected override void OnVisualize() } } - public static void ProcessInterfacer(AbilityDataItem facer) + public static Command GetProcessInterfacer(AbilityDataItem facer) { if (facer == null) { Debug.LogError("Boom"); - return; + return null; } switch (facer.InformationGather) { @@ -138,8 +138,13 @@ public static void ProcessInterfacer(AbilityDataItem facer) break; } - Send(curCom); + return curCom; } + public static void ProcessInterfacer (AbilityDataItem facer) { + Command com = GetProcessInterfacer (facer); + Send(com); + } + protected virtual void OnGUI() { diff --git a/Core/Game/Player/SelectionManager.cs b/Core/Game/Player/SelectionManager.cs index 262233b7..3b1769bd 100644 --- a/Core/Game/Player/SelectionManager.cs +++ b/Core/Game/Player/SelectionManager.cs @@ -296,7 +296,7 @@ public static float DotEdge() private static void GetMousedAgent() { - if (EventSystem.current.IsPointerOverGameObject()) { + if (EventSystem.current != null && EventSystem.current.IsPointerOverGameObject()) { return; } diff --git a/Core/Game/Player/Utility/Selector.cs b/Core/Game/Player/Utility/Selector.cs index 52c7a613..889231a7 100644 --- a/Core/Game/Player/Utility/Selector.cs +++ b/Core/Game/Player/Utility/Selector.cs @@ -66,6 +66,7 @@ public static void Clear() if (selectedAgents.arrayAllocation [j]) { selectedAgents [j].IsSelected = false; + onRemove (selectedAgents[j]); } } selectedAgents.FastClear(); diff --git a/Core/Simulation/Grid/Influence/LSInfluencer.cs b/Core/Simulation/Grid/Influence/LSInfluencer.cs index 8d7246e7..32cfe83a 100644 --- a/Core/Simulation/Grid/Influence/LSInfluencer.cs +++ b/Core/Simulation/Grid/Influence/LSInfluencer.cs @@ -44,6 +44,9 @@ public void Simulate () if (Body.PositionChangedBuffer) { tempNode = GridManager.GetNode (Body._position.x, Body._position.y); + if (tempNode.IsNull()) + return; + if (System.Object.ReferenceEquals (tempNode, LocatedNode) == false) { LocatedNode.Remove (this); tempNode.Add (this); diff --git a/Core/Utility/Fast/FastQueue.cs b/Core/Utility/Fast/FastQueue.cs index ad356c5f..f3b3aea8 100644 --- a/Core/Utility/Fast/FastQueue.cs +++ b/Core/Utility/Fast/FastQueue.cs @@ -41,6 +41,14 @@ public T Pop() { Count--; return ret; } + public T Peek () { + return innerArray[head]; + } + public T PeekTail () { + int tailIndex = tail - 1; + if (tailIndex < 0) tailIndex = this.Capacity - 1; + return innerArray[tailIndex]; + } public void SetCapacity(int min) { if (Capacity < min) { @@ -80,5 +88,6 @@ public T[] ToArray() { } return result; } + } } \ No newline at end of file diff --git a/Database/Scripts/Default/DataItemTemplates/PathObjectDataItem.cs b/Database/Scripts/Default/DataItemTemplates/PathObjectDataItem.cs new file mode 100644 index 00000000..cd83f021 --- /dev/null +++ b/Database/Scripts/Default/DataItemTemplates/PathObjectDataItem.cs @@ -0,0 +1,14 @@ +using UnityEngine; +using System.Collections; + +namespace Lockstep.Data +{ + [System.Serializable] + public class PathObjectDataItem : MetaDataItem + { + [SerializeField] + private PathObject _object; + + public PathObject Object { get { return _object; } } + } +} \ No newline at end of file diff --git a/Database/Scripts/Default/DataItemTemplates/PathObjectDataItem.cs.meta b/Database/Scripts/Default/DataItemTemplates/PathObjectDataItem.cs.meta new file mode 100644 index 00000000..47d636af --- /dev/null +++ b/Database/Scripts/Default/DataItemTemplates/PathObjectDataItem.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 601d99c1646e04be19dade82d47fd754 +timeCreated: 1458067610 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: