Weapos Rejiggered
Modified weapon scripts to eliminate specialized projectile behavior - allows charged weapons to have projectiles and modify weapon stats when charged Added machine gun weapon & VFX Moved third party code to Plugins folder to improve compile times
This commit is contained in:
parent
2a0fe34611
commit
dbc522a224
2105 changed files with 7033 additions and 1141 deletions
|
|
@ -0,0 +1,106 @@
|
|||
// Copyright (c) All contributors. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using MessagePack.Formatters;
|
||||
using UniRx;
|
||||
|
||||
#pragma warning disable SA1649 // File name should match first type name
|
||||
|
||||
namespace MessagePack.ReactivePropertyExtension
|
||||
{
|
||||
public class ReactivePropertyFormatter<T> : IMessagePackFormatter<ReactiveProperty<T>>
|
||||
{
|
||||
public void Serialize(ref MessagePackWriter writer, ReactiveProperty<T> value, MessagePackSerializerOptions options)
|
||||
{
|
||||
if (value == null)
|
||||
{
|
||||
writer.WriteNil();
|
||||
}
|
||||
else
|
||||
{
|
||||
options.Resolver.GetFormatterWithVerify<T>().Serialize(ref writer, value.Value, options);
|
||||
}
|
||||
}
|
||||
|
||||
public ReactiveProperty<T> Deserialize(ref MessagePackReader reader, MessagePackSerializerOptions options)
|
||||
{
|
||||
if (reader.TryReadNil())
|
||||
{
|
||||
return null;
|
||||
}
|
||||
else
|
||||
{
|
||||
T v = options.Resolver.GetFormatterWithVerify<T>().Deserialize(ref reader, options);
|
||||
|
||||
return new ReactiveProperty<T>(v);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class ReactiveCollectionFormatter<T> : CollectionFormatterBase<T, ReactiveCollection<T>>
|
||||
{
|
||||
protected override void Add(ReactiveCollection<T> collection, int index, T value, MessagePackSerializerOptions options)
|
||||
{
|
||||
collection.Add(value);
|
||||
}
|
||||
|
||||
protected override ReactiveCollection<T> Create(int count, MessagePackSerializerOptions options)
|
||||
{
|
||||
return new ReactiveCollection<T>();
|
||||
}
|
||||
}
|
||||
|
||||
public class UnitFormatter : IMessagePackFormatter<Unit>
|
||||
{
|
||||
public static readonly UnitFormatter Instance = new UnitFormatter();
|
||||
|
||||
private UnitFormatter()
|
||||
{
|
||||
}
|
||||
|
||||
public void Serialize(ref MessagePackWriter writer, Unit value, MessagePackSerializerOptions options)
|
||||
{
|
||||
writer.WriteNil();
|
||||
}
|
||||
|
||||
public Unit Deserialize(ref MessagePackReader reader, MessagePackSerializerOptions options)
|
||||
{
|
||||
if (reader.TryReadNil())
|
||||
{
|
||||
return Unit.Default;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new InvalidOperationException("Invalid Data type. Code: " + MessagePackCode.ToFormatName(reader.NextCode));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class NullableUnitFormatter : IMessagePackFormatter<Unit?>
|
||||
{
|
||||
public static readonly NullableUnitFormatter Instance = new NullableUnitFormatter();
|
||||
|
||||
private NullableUnitFormatter()
|
||||
{
|
||||
}
|
||||
|
||||
public void Serialize(ref MessagePackWriter writer, Unit? value, MessagePackSerializerOptions options)
|
||||
{
|
||||
writer.WriteNil();
|
||||
}
|
||||
|
||||
public Unit? Deserialize(ref MessagePackReader reader, MessagePackSerializerOptions options)
|
||||
{
|
||||
if (reader.TryReadNil())
|
||||
{
|
||||
return Unit.Default;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new InvalidOperationException("Invalid Data type. Code: " + MessagePackCode.ToFormatName(reader.NextCode));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 2ba66c25dd4bca148a26245df562577b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,75 @@
|
|||
// Copyright (c) All contributors. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
using MessagePack.Formatters;
|
||||
using UniRx;
|
||||
|
||||
namespace MessagePack.ReactivePropertyExtension
|
||||
{
|
||||
public class ReactivePropertyResolver : IFormatterResolver
|
||||
{
|
||||
public static readonly ReactivePropertyResolver Instance = new ReactivePropertyResolver();
|
||||
|
||||
private ReactivePropertyResolver()
|
||||
{
|
||||
}
|
||||
|
||||
public IMessagePackFormatter<T> GetFormatter<T>()
|
||||
{
|
||||
return FormatterCache<T>.Formatter;
|
||||
}
|
||||
|
||||
private static class FormatterCache<T>
|
||||
{
|
||||
internal static readonly IMessagePackFormatter<T> Formatter;
|
||||
|
||||
static FormatterCache()
|
||||
{
|
||||
Formatter = (IMessagePackFormatter<T>)ReactivePropertyResolverGetFormatterHelper.GetFormatter(typeof(T));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
internal static class ReactivePropertyResolverGetFormatterHelper
|
||||
{
|
||||
private static readonly Dictionary<Type, Type> FormatterMap = new Dictionary<Type, Type>()
|
||||
{
|
||||
{ typeof(ReactiveProperty<>), typeof(ReactivePropertyFormatter<>) },
|
||||
{ typeof(ReactiveCollection<>), typeof(ReactiveCollectionFormatter<>) },
|
||||
};
|
||||
|
||||
internal static object GetFormatter(Type t)
|
||||
{
|
||||
if (t == typeof(Unit))
|
||||
{
|
||||
return UnitFormatter.Instance;
|
||||
}
|
||||
else if (t == typeof(Unit?))
|
||||
{
|
||||
return NullableUnitFormatter.Instance;
|
||||
}
|
||||
|
||||
TypeInfo ti = t.GetTypeInfo();
|
||||
|
||||
if (ti.IsGenericType)
|
||||
{
|
||||
Type genericType = ti.GetGenericTypeDefinition();
|
||||
Type formatterType;
|
||||
if (FormatterMap.TryGetValue(genericType, out formatterType))
|
||||
{
|
||||
return CreateInstance(formatterType, ti.GenericTypeArguments);
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private static object CreateInstance(Type genericType, Type[] genericTypeArguments, params object[] arguments)
|
||||
{
|
||||
return Activator.CreateInstance(genericType.MakeGenericType(genericTypeArguments), arguments);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 9605defad6e10ba4e910ed209eb12b08
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Loading…
Reference in a new issue