Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
Majiir committed Oct 22, 2018
2 parents da22583 + 3a2ffff commit de2c691
Show file tree
Hide file tree
Showing 26 changed files with 1,003 additions and 210 deletions.
623 changes: 439 additions & 184 deletions Subsystem/AttributeLoader.cs

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using BBI.Game.Data;

namespace Subsystem
namespace Subsystem.Patch
{
public class AbilityAttributesPatch
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System.Collections.Generic;

namespace Subsystem
namespace Subsystem.Patch
{
public class AttributesPatch
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
using System.Collections.Generic;

namespace Subsystem
namespace Subsystem.Patch
{
public class EntityTypePatch
{
public UnitAttributesPatch UnitAttributes { get; set; }
public ResearchItemAttributesPatch ResearchItemAttributes { get; set; }
public UnitHangarAttributesPatch UnitHangarAttributes { get; set; }
public UnitMovementAttributesPatch UnitMovementAttributes { get; set; }
public Dictionary<string, AbilityAttributesPatch> AbilityAttributes { get; set; } = new Dictionary<string, AbilityAttributesPatch>();
public Dictionary<string, WeaponAttributesPatch> WeaponAttributes { get; set; } = new Dictionary<string, WeaponAttributesPatch>();
}
Expand Down
33 changes: 33 additions & 0 deletions Subsystem/Patch/HangarBayPatch.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
using BBI.Game.Data;

namespace Subsystem.Patch
{
public class HangarBayPatch
{
public string EntityType { get; set; }
public int? MaxCount { get; set; }
public bool? UsesStrictClassMatching { get; set; }
public UnitClass? HoldsClass { get; set; }
public int? SlotCount { get; set; }
public string UndockPresCtrlBone { get; set; }
public double? UndockTotalSeconds { get; set; }
public double? UndockAnimationSeconds { get; set; }
public double? UndockSlotStaggerSeconds { get; set; }
public double? UndockXOffsetPos { get; set; }
public double? UndockYOffsetPos { get; set; }
public double? UndockSlotXSeperationOffset { get; set; }
public double? DegreesOffsetUndockAngle { get; set; }
public double? UndockSpeed { get; set; }
public string DockPresCtrlBone { get; set; }
public double? DockBringInAnimationSeconds { get; set; }
public double? DockSlotStaggerSeconds { get; set; }
public double? MaxDamageCoolingSeconds { get; set; }
public double? MaxPayloadCoolingSeconds { get; set; }
public double? MinDockCoolingSeconds { get; set; }
public double? DockReceivingXOffset { get; set; }
public double? DockReceivingYOffset { get; set; }
public double? DoorAnimationSeconds { get; set; }
public double? UndockLiftTime { get; set; }

}
}
10 changes: 10 additions & 0 deletions Subsystem/Patch/RangeBasedWeaponAttributesPatch.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
namespace Subsystem.Patch
{
public class RangeBasedWeaponAttributesPatch
{
public double? Accuracy { get; set; }
public double? Distance { get; set; }
public double? MinDistance { get; set; }
public bool Remove { get; set; }
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using BBI.Game.Data;

namespace Subsystem
namespace Subsystem.Patch
{
public class ResearchItemAttributesPatch
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using BBI.Game.Data;

namespace Subsystem
namespace Subsystem.Patch
{
public class UnitAttributesPatch
{
Expand Down
28 changes: 28 additions & 0 deletions Subsystem/Patch/UnitDynamicsAttributesPatch.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
using BBI.Game.Data;

namespace Subsystem.Patch
{
public class UnitDynamicsAttributesPatch
{
public UnitDriveType? DriveType { get; set; }
public double? Length { get; set; }
public double? Width { get; set; }
public double? MaxSpeed { get; set; }
public double? ReverseFactor { get; set; }
public double? AccelerationTime { get; set; }
public double? BrakingTime { get; set; }
public double? MaxSpeedTurnRadius { get; set; }
public double? MaxEaseIntoTurnTime { get; set; }
public double? DriftType { get; set; }
public double? ReverseDriftMultiplier { get; set; }
public double? DriftOvershootFactor { get; set; }
public double? FishTailingTimeIntervals { get; set; }
public double? FishTailControlRecover { get; set; }
public double? MinDriftSlipSpeed { get; set; }
public double? MaxDriftRecoverTime { get; set; }
public double? MinCruiseSpeed { get; set; }
public double? DeathDriftTime { get; set; }
public bool? PermanentlyImmobile { get; set; }

}
}
11 changes: 11 additions & 0 deletions Subsystem/Patch/UnitHangarAttributesPatch.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
using System.Collections.Generic;

namespace Subsystem.Patch
{
public class UnitHangarAttributesPatch
{
public Dictionary<string, HangarBayPatch> HangarBays { get; set; } = new Dictionary<string, HangarBayPatch>();
public double? AlignmentTime { get; set; }
public double? ApproachTime { get; set; }
}
}
10 changes: 10 additions & 0 deletions Subsystem/Patch/UnitMovementAttributesPatch.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
using BBI.Game.Data;

namespace Subsystem.Patch
{
public class UnitMovementAttributesPatch
{
public UnitDriveType? DriveType { get; set; }
public UnitDynamicsAttributesPatch Dynamics { get; set; }
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using BBI.Game.Data;
namespace Subsystem

namespace Subsystem.Patch
{
public class WeaponAttributesPatch
{
Expand Down Expand Up @@ -33,6 +34,9 @@ public class WeaponAttributesPatch
public bool? ExcludeWeaponOwnerFromAreaOfEffect { get; set; }
public double? FriendlyFireDamageScalar { get; set; }
public double? WeaponOwnerFriendlyFireDamageScalar { get; set; }
public RangeBasedWeaponAttributesPatch RangeAttributesShort { get; set; }
public RangeBasedWeaponAttributesPatch RangeAttributesMedium { get; set; }
public RangeBasedWeaponAttributesPatch RangeAttributesLong { get; set; }
public string ProjectileEntityTypeToSpawn { get; set; }
public AbilityTargetAlignment? StatusEffectsTargetAlignment { get; set; }
public UnitClass? StatusEffectsExcludeTargetType { get; set; }
Expand Down
2 changes: 1 addition & 1 deletion Subsystem/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,4 @@
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("0.2.0")]
[assembly: AssemblyInformationalVersion("0.3.0")]
41 changes: 41 additions & 0 deletions Subsystem/PropertyAccessor.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
using System;
using System.Linq.Expressions;
using System.Reflection;

namespace Subsystem
{
public class PropertyAccessor<T>
{
private Func<T> getter;
private Action<T> setter;

public T Get() => getter();
public void Set(T value) => setter(value);
public string Name { get; private set; }

public PropertyAccessor(Expression<Func<T>> expression)
{
var memberExpression = expression.Body as MemberExpression;

if (memberExpression == null)
{
throw new ArgumentException("must be a MemberExpression", nameof(expression));
}

var instanceExpression = memberExpression.Expression;
var parameter = Expression.Parameter(typeof(T), "obj");

var propertyInfo = memberExpression.Member as PropertyInfo;

if (propertyInfo == null)
{
throw new ArgumentException("must refer to a property", nameof(expression));
}

Name = propertyInfo.Name;

getter = Expression.Lambda<Func<T>>(Expression.Call(instanceExpression, propertyInfo.GetGetMethod())).Compile();
setter = Expression.Lambda<Action<T>>(Expression.Call(instanceExpression, propertyInfo.GetSetMethod(), parameter), parameter).Compile();
}
}
}
130 changes: 130 additions & 0 deletions Subsystem/StringLogger.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.IO;
using System.Linq;

namespace Subsystem
{
public class StringLogger
{
private readonly Stack<Scope> scopes = new Stack<Scope>();

public StringLogger()
{
scopes.Push(new Scope());
}

public IDisposable BeginScope(string name)
{
var scope = scopes.Peek();
var newScope = scope.CreateScope(name);
scopes.Push(newScope);
return new ScopeDisposer(this);
}

public void Log(string log)
{
scopes.Peek().AddLog(log);
}

public string GetLog()
{
var writer = new StringWriter();
WriteLog(writer);
return writer.ToString();
}

public void WriteLog(TextWriter writer)
{
writeLog(writer, scopes.Peek(), indent: 0);
}

private void writeLog(TextWriter writer, Scope scope, int indent)
{
foreach (var logEntry in scope.LogEntries)
{
writeIndent(writer, indent);
writer.WriteLine(logEntry.Log);
}

if (scope.LogEntries.Any())
{
writer.WriteLine();
}

foreach (var kvp in scope.Scopes)
{
var childScopeName = kvp.Key;
var childScope = kvp.Value;

writeIndent(writer, indent);
writer.WriteLine(childScopeName);
writer.WriteLine();

writeLog(writer, childScope, indent + 1);
}
}

private static void writeIndent(TextWriter writer, int indent)
{
for (var i = 0; i < indent; i++)
{
writer.Write(" ");
}
}

private class ScopeDisposer : IDisposable
{
private readonly StringLogger logger;

public ScopeDisposer(StringLogger logger)
{
this.logger = logger;
}

public void Dispose()
{
logger.scopes.Pop();
}
}

private class Scope
{
public IList<KeyValuePair<string, Scope>> Scopes
{
get { return new ReadOnlyCollection<KeyValuePair<string, Scope>>(scopes); }
}

public IList<LogEntry> LogEntries
{
get { return new ReadOnlyCollection<LogEntry>(logEntries); }
}

private readonly List<KeyValuePair<string, Scope>> scopes = new List<KeyValuePair<string, Scope>>();
private readonly List<LogEntry> logEntries = new List<LogEntry>();

public void AddLog(string log)
{
logEntries.Add(new LogEntry(log));
}

public Scope CreateScope(string name)
{
var scope = new Scope();
scopes.Add(new KeyValuePair<string, Scope>(name, scope));
return scope;
}
}

private class LogEntry
{
public string Log { get; private set; }

public LogEntry(string log)
{
Log = log;
}
}
}
}
Loading

0 comments on commit de2c691

Please sign in to comment.