Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions Core/Game/Abilities/Ability.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,7 @@ protected set
}
}
}




internal void Setup(LSAgent agent, int id)
{
System.Type mainType = this.GetType();
Expand Down
21 changes: 19 additions & 2 deletions Core/Game/Abilities/Essential/Move.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -104,6 +106,12 @@ public long timescaledSpeed
private long closingDistance;
private long stuckTolerance;

[Lockstep (true)]
public bool SlowArrival {
get;
set;
}

#region Serialized

[SerializeField]
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -305,7 +314,12 @@ protected override void OnSimulate()
Arrive();
return;
}
desiredVelocity = (movementDirection * (distance) / (closingDistance));
if (this.SlowArrival) {
desiredVelocity = (movementDirection * (distance) / (closingDistance));
}
else {
desiredVelocity = (movementDirection);
}
}


Expand Down Expand Up @@ -335,6 +349,7 @@ protected override void OnSimulate()

protected override void OnExecute(Command com)
{

if (com.ContainsData<Vector2d> ())
{
Agent.StopCast(ID);
Expand Down Expand Up @@ -439,6 +454,8 @@ public void StartMove(Vector2d destination)
IsCasting = true;
stuckTick = 0;
forcePathfind = false;
if (onStartMove != null)
onStartMove ();
}
}

Expand Down
14 changes: 7 additions & 7 deletions Core/Game/Agents/Visuals/Materials/Hex.mat
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand All @@ -99,7 +99,7 @@ Material:
data:
first:
name: _ZWrite
second: 0
second: 1
data:
first:
name: _Glossiness
Expand All @@ -123,7 +123,7 @@ Material:
data:
first:
name: _Mode
second: 2
second: 1
data:
first:
name: _Metallic
Expand Down
Binary file modified Core/Game/Agents/Visuals/Textures/Circle.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion Core/Game/Agents/Visuals/Textures/Circle.png.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 17 additions & 4 deletions Core/Game/Player/Commands/Command.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
using System;
using System.Collections.Generic;
using UnityEngine;
using System.Linq;
using System.Reflection;
namespace Lockstep
{
public partial class Command
Expand All @@ -21,22 +23,33 @@ public static void Setup () {
private static BiDictionary<Type, ushort> RegisteredData = new BiDictionary<Type, ushort>();

static void RegisterDefaults () {
Register<DefaultData> ();
/*Register<DefaultData> ();
Register<Vector2d> ();
Register<Selection> ();
Register<Vector2dHeight> ();
Register<Coordinate> ();
Register<Vector3d>();
Register<EmptyData> ();*/
foreach (Type t in Assembly.GetCallingAssembly().GetTypes())
{
if (t.GetInterface("ICommandData") != null)
{
Register (t);
}
}
}

public static void Register<TData>() where TData : ICommandData
private static void Register<TData>() 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;
Expand Down
15 changes: 15 additions & 0 deletions Core/Game/Player/Commands/Default/EmptyData.cs
Original file line number Diff line number Diff line change
@@ -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) {

}
}
}
12 changes: 12 additions & 0 deletions Core/Game/Player/Commands/Default/EmptyData.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 1 addition & 3 deletions Core/Game/Player/RTSInterfacing.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,7 @@ public static LSAgent GetScreenAgent (Vector2 screenPos, Func<LSAgent, bool> con

public static void Visualize ()
{
if (EventSystem.current.IsPointerOverGameObject()) {
return;
}

if (mainCamera .IsNotNull ()) {
CachedRay = mainCamera.ScreenPointToRay (Input.mousePosition);
CachedDidHit = NDRaycast.Raycast (CachedRay, out CachedHit);
Expand Down
11 changes: 8 additions & 3 deletions Core/Game/Player/RTSInterfacingHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down Expand Up @@ -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()
{
Expand Down
2 changes: 1 addition & 1 deletion Core/Game/Player/SelectionManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ public static float DotEdge()

private static void GetMousedAgent()
{
if (EventSystem.current.IsPointerOverGameObject()) {
if (EventSystem.current != null && EventSystem.current.IsPointerOverGameObject()) {
return;
}

Expand Down
1 change: 1 addition & 0 deletions Core/Game/Player/Utility/Selector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ public static void Clear()
if (selectedAgents.arrayAllocation [j])
{
selectedAgents [j].IsSelected = false;
onRemove (selectedAgents[j]);
}
}
selectedAgents.FastClear();
Expand Down
3 changes: 3 additions & 0 deletions Core/Simulation/Grid/Influence/LSInfluencer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
9 changes: 9 additions & 0 deletions Core/Utility/Fast/FastQueue.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -80,5 +88,6 @@ public T[] ToArray() {
}
return result;
}

}
}
14 changes: 14 additions & 0 deletions Database/Scripts/Default/DataItemTemplates/PathObjectDataItem.cs
Original file line number Diff line number Diff line change
@@ -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; } }
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.