Compare commits

28 Commits

Author SHA1 Message Date
9bd1b3cd4a feat: Sample Air Movement Updated
- AirMovement1D updated to slow down if it's going faster than the BaseSpeed along X axis
2023-03-21 16:31:01 +03:00
119cc2c628 docs: Updated README.md 2023-03-21 16:31:00 +03:00
8650d3806b feat: Added Sample Scene 2023-03-21 16:31:00 +03:00
d98e741a6e refactor: Added Backing Fields to BaseSpeed & MovementMultiplier to Expose to Editor 2023-03-21 16:05:55 +03:00
a4bb04860c feat: Sample Movements Are Now Looking Up Parents For Rigidbodies 2023-03-20 22:51:49 +03:00
0fc73f330b refactor: Replaced "Member" IStateEnable 2023-03-20 22:51:19 +03:00
25be6929f2 BREAKING CHANGE: Toggle 0.2.0 2023-03-20 22:39:21 +03:00
d11aab596d Fixed Movement Controller not updating the new movement with the old information 2023-01-19 20:13:12 +03:00
57790c4598 Editor Fix 2022-12-18 23:51:27 +03:00
c244ddeb98 Moved few Implemantations to Samples Folder 2022-12-17 12:04:14 +03:00
e95462af00 Changed Some Fields 2022-12-17 11:59:08 +03:00
fa521c0e7e Typo Fix 2022-12-15 19:54:43 +03:00
3e7b69db6f Removed Dependencies from package.json
Because they were causing problems that don't have the scoped registry set
2022-12-15 19:50:29 +03:00
166b67d8be Dependency SemVer Update 2022-12-15 19:40:28 +03:00
36ec79c262 Unity Package Structure 2022-12-15 19:24:01 +03:00
f84502ceb4 Package.json Updated 2022-12-13 14:22:07 +03:00
d0a1186142 Fix 2022-12-13 14:07:42 +03:00
7ea16843ed Meta Files and Fix 2022-12-13 14:06:01 +03:00
5e87456f4c Package.json 2022-12-13 13:56:53 +03:00
72b3489362 Impovement 2022-12-02 00:09:54 +03:00
70edb0e5a1 Improved OnMoveCalled on MovementController 2022-12-02 00:02:39 +03:00
fc22863f57 Controller Improvements 2022-12-01 23:30:02 +03:00
ca589f1244 Factory Update 2022-11-21 21:57:25 +03:00
d03fa51010 Factory Update 2022-11-21 21:51:27 +03:00
c9d8b5617e Update Readme 2022-11-21 21:04:57 +03:00
df02a4fbd7 Removed Submodules 2022-11-21 21:02:23 +03:00
f25a9b676b Editor Updated & Cleanup 2022-11-21 14:01:01 +03:00
4305d26d17 Factory Submodule Added 2022-11-21 13:51:55 +03:00
58 changed files with 931 additions and 145 deletions

6
.gitmodules vendored
View File

@@ -1,6 +0,0 @@
[submodule "ToggleState"]
path = ToggleState
url = git@git.syntriax.com:Syntriax/ToggleState.git
[submodule "Trigger"]
path = Trigger
url = git@git.syntriax.com:Syntriax/Trigger.git

View File

@@ -3,6 +3,7 @@ using UnityEditor;
using UnityEditorInternal;
using Syntriax.Modules.Movement.Config;
using System;
using Syntriax.Modules.Factory;
namespace Syntriax.Modules.Movement.Editor
{
@@ -55,12 +56,12 @@ namespace Syntriax.Modules.Movement.Editor
GUILayout.Space(10);
GUILayout.Label("Tip: MovementConfigs->TypeName and MonoBehaviours have the same naming system");
GUILayout.Label("Tip: MovementConfigs->TypeName and MonoBehaviours use the type.FullName value");
GUILayout.Label("If under a namespace: \"Namespace.ClassName\"");
GUILayout.Label("If not under a namespace: \"ClassName\"");
GUILayout.Space(5);
GUILayout.Label($"Tip: Apply these to your GameObjects by using {nameof(MovementDefinitionFactory)}");
GUILayout.Label($"{nameof(MovementDefinitionFactory)}.Instance.ApplyDefinitionToGameObject(\"{movementName.stringValue}\");");
GUILayout.Label($"Tip: Apply these to your GameObjects by using {nameof(MovementDefinitionFactory)} or the {nameof(MovementDefinitionApplier)} component");
GUILayout.Label($"{nameof(FactorySingleton<MovementDefinitionFactory>)}<{nameof(MovementDefinitionFactory)}>.Instance.ApplyDefinitionToGameObject(\"{movementName.stringValue}\");");
if (quickPresetButtonPressed) LoadPresetQuick();
if (longerPresetButtonPressed) LoadPresetLonger();
@@ -74,12 +75,12 @@ namespace Syntriax.Modules.Movement.Editor
movementDefinition.MovementConfigs = new MovementConfig[]
{
new MovementConfig(MovementFactory.GetTypeName(typeof(Implementations.GroundMovement1D)), 5f)
new MovementConfig(typeof(Samples.GroundMovement1D).FullName, 5f)
};
movementDefinition.MonoBehaviours = new string[]
{
MovementFactory.GetTypeName(typeof(MovementController))
typeof(MovementController).FullName
};
UpdateSerializedObject();
@@ -91,14 +92,14 @@ namespace Syntriax.Modules.Movement.Editor
movementDefinition.MovementConfigs = new MovementConfig[]
{
new MovementConfig(MovementFactory.GetTypeName(typeof(Implementations.AirMovement1D)), 5f),
new MovementConfig(MovementFactory.GetTypeName(typeof(Implementations.GroundMovement1D)), 5f)
new MovementConfig(typeof(Samples.AirMovement1D).FullName, 5f),
new MovementConfig(typeof(Samples.GroundMovement1D).FullName, 5f)
};
movementDefinition.MonoBehaviours = new string[]
{
MovementFactory.GetTypeName(typeof(MovementController)),
MovementFactory.GetTypeName(typeof(ToggleState.ToggleStateMonoBehaviour))
typeof(MovementController).FullName,
typeof(State.StateEnableMonoBehaviour).FullName
};
UpdateSerializedObject();
@@ -141,8 +142,9 @@ namespace Syntriax.Modules.Movement.Editor
string jsonText = JsonUtility.ToJson(definition, true);
string path = $"Assets/Resources/{MovementDefinitionFactory.ResourceDirectoryToDefinitions}{definition.Name}.json";
if (!EditorUtility.DisplayDialog("Conflict", $"\"{path}\" already exists, do you want to overwrite?", "Overwrite", "Cancel"))
return;
if (System.IO.File.Exists($"{Application.dataPath}/Resources/{MovementDefinitionFactory.ResourceDirectoryToDefinitions}{definition.Name}.json"))
if (!EditorUtility.DisplayDialog("Conflict", $"\"{path}\" already exists, do you want to overwrite?", "Overwrite", "Cancel"))
return;
System.IO.File.WriteAllText(path, jsonText);
AssetDatabase.Refresh();

View File

@@ -0,0 +1,21 @@
{
"name": "Syntriax.Modules.Movement.Editor",
"rootNamespace": "",
"references": [
"GUID:d4c952ed5f59c5a449cda1b0080ed841",
"GUID:efa9a9bc94c60c74684aafb7428fbf61",
"GUID:c967acc4be781ca44b42a1887eb1ac7a",
"GUID:863b8995abde2cf40b8b4cb709452a32"
],
"includePlatforms": [
"Editor"
],
"excludePlatforms": [],
"allowUnsafeCode": false,
"overrideReferences": false,
"precompiledReferences": [],
"autoReferenced": true,
"defineConstraints": [],
"versionDefines": [],
"noEngineReferences": false
}

View File

@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 9cf72248c45dc1749bdfa757cd33e109
AssemblyDefinitionImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,12 +1,28 @@
# Movement (Work In Progress)
## Dependencies
1. [ToggleState Module](https://git.syntriax.com/Syntriax/ToggleState)
2. [Trigger Module](https://git.syntriax.com/Syntriax/Trigger)
## Installation
### UPM
1. Add the UPM registry. Click on the `Edit` menu, then select `Project settings...`, select `Package Manager`, and add a scoped registry:
- Name: `Syntriax`
- Url: `https://upm.syntriax.com`
- Scopes:
- `com.syntriax`
Make sure to separately clone these modules along with this one too.
The UPM registry also has proxies to OpenUPM, so you can add scopes from there too.
Or you can call ```git submodule init``` to get them automatically added (note that this method may cause conflicts if another module also imports one of these submodules too, only use if you are only using the `Movement` module)
### Manual
1. Navigate into `Package Manager` and press on the `+` button, choose `Add package from git URL...` and add:
- `https://git.syntriax.com/Syntriax/State`
- `https://git.syntriax.com/Syntriax/Trigger`
- `https://git.syntriax.com/Syntriax/Factory`
- `https://git.syntriax.com/Syntriax/Movement`
---
### Dependencies
1. [State Module (https://git.syntriax.com/Syntriax/State)](https://git.syntriax.com/Syntriax/State)
2. [Trigger Module (https://git.syntriax.com/Syntriax/Trigger)](https://git.syntriax.com/Syntriax/Trigger)
3. [Factory Module (https://git.syntriax.com/Syntriax/Factory)](https://git.syntriax.com/Syntriax/Factory)
---
@@ -33,17 +49,17 @@ Or you can call ```git submodule init``` to get them automatically added (note t
#### Longer
1. Clone the module to a folder in your Assets folder
2. Add `ToggleStateMonoBehaviour` component to your Player `GameObject`
2. Add `StateEnableMonoBehaviour` component to your Player `GameObject`
3. Add `MovementController` component to your Player `GameObject`
4. Add `AirMovement1D` component to your Player `GameObject`
5. Add `GroundMovement1D` component to your Player `GameObject` (make sure it's bellow `AirMovement1D`)
6. Add a new empty child `GameObject` and add `Box2DColliderTrigger` component to it and place and resize it under the player for ground detection, optionally you can set the `CollisionMask` field on it to make sure it only detects specific layers
6. Add a new empty child `GameObject` and add `Box2DGroundTrigger` & `GroundTrigger` component to it and place and resize it under the player for ground detection, optionally you can set the `CollisionMask` field on it to make sure it only detects specific layers
7. Connect your inputs to the `MovementController` ([Example with Input System](#input-system-example))
8. (Optional) Add a jumping script to see the effects better
---
This should give you a movement where you can disable the controller through the `IToggleState`, and you should be able to see a the movement changes when the character is not touching the ground.
This should give you a movement where you can disable the controller through the `IStateEnable`, and you should be able to see a the movement changes when the character is not touching the ground.
You can add your own movement implementations with bases under the `Bases` folder, or straight up from the `IMovement` interface.

View File

@@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: 461182bc375cc354bbb3e45db52bdf3f
guid: 265853a3d06f03c4b9b926b0bc411285
folderAsset: yes
DefaultImporter:
externalObjects: {}

View File

@@ -1,16 +1,18 @@
using System;
using Syntriax.Modules.ToggleState;
using Syntriax.Modules.State;
using UnityEngine;
namespace Syntriax.Modules.Movement
{
public abstract class MovementBase : MonoBehaviour, IMovement
{
protected IToggleState toggleState = null;
protected IStateEnable stateEnable = null;
protected IMovementController movementController = null;
public float BaseSpeed { get; set; } = 1f;
public float MovementMultiplier { get; set; } = 1f;
[SerializeField] private float _baseSpeed = 1f;
public float BaseSpeed { get => _baseSpeed; set => _baseSpeed = value; }
[SerializeField] private float _movementMultiplier = 1f;
public float MovementMultiplier { get => _movementMultiplier; set => _movementMultiplier = value; }
public Action<bool> OnTakeOverStateChanged { get; set; } = null;
private bool _canTakeOver = false;
@@ -19,17 +21,14 @@ namespace Syntriax.Modules.Movement
get => _canTakeOver;
protected set
{
bool oldValue = _canTakeOver;
if (value == _canTakeOver)
return;
_canTakeOver = value;
if (oldValue != value)
OnTakeOverStateChanged?.Invoke(value);
OnTakeOverStateChanged?.Invoke(value);
}
}
public IToggleState ToggleState { get; protected set; } = null;
/// <inheritdoc/>
public abstract void ApplyMovement();
@@ -47,7 +46,7 @@ namespace Syntriax.Modules.Movement
protected virtual void Start()
{
toggleState = GetComponent<IToggleState>();
stateEnable = GetComponent<IStateEnable>();
movementController = GetComponent<IMovementController>();
movementController.OnMovementActivated += OnActivated;

View File

@@ -1,4 +1,5 @@
using System.Collections.Generic;
using Syntriax.Modules.Factory;
using UnityEngine;
namespace Syntriax.Modules.Movement.Config
@@ -10,44 +11,27 @@ namespace Syntriax.Modules.Movement.Config
/// <para> Looks for the path specified in the variable <see cref="ResourceDirectoryToDefinitions"/></para>
/// <para> The default path is "Resources/Modules/Syntriax/Movement/Definitions/"</para>
/// </remarks>
public class MovementDefinitionFactory : MonoBehaviour
public class MovementDefinitionFactory : FactoryBase
{
internal const string Name = "Movement Definition Factory";
internal const int InitialCapacity = 64;
internal const string ResourceDirectoryToDefinitions = "Modules/Syntriax/Movement/Definitions/";
private static MovementDefinitionFactory _instance = null;
public static MovementDefinitionFactory Instance
{
get
{
if (_instance == null)
{
GameObject factoriesGO = GameObject.Find("Factories") ?? new GameObject("Factories");
_instance = new GameObject(Name).AddComponent<MovementDefinitionFactory>();
_instance.transform.SetParent(factoriesGO.transform);
DontDestroyOnLoad(factoriesGO);
}
return _instance;
}
}
public const int InitialCapacity = 64;
public const string ResourceDirectoryToDefinitions = "Modules/Syntriax/Movement/Definitions/";
private Dictionary<string, MovementDefinition> _definitions = null;
public Dictionary<string, MovementDefinition> Definitions
{
get
{
if (_definitions == null)
if (!IsInitialized)
Initialize();
return _definitions;
}
}
private void Start()
{
if (_instance == this)
if (FactorySingleton<MovementDefinitionFactory>.Instance == this)
return;
Destroy(this);
@@ -60,17 +44,23 @@ namespace Syntriax.Modules.Movement.Config
/// <para> Automatically loads the definition files specificed path <see cref="ResourceDirectoryToDefinitions"/></para>
/// <para> The default is "Resources/Modules/Syntriax/Movement/Definitions/"</para>
/// </remarks>
public void Initialize()
protected override void OnFactoryInitialize()
{
if (_definitions == null)
_definitions = new Dictionary<string, MovementDefinition>(InitialCapacity);
Reset();
foreach (TextAsset definitionTextAsset in UnityEngine.Resources.LoadAll<TextAsset>(ResourceDirectoryToDefinitions))
AddToFactoryWithJSON(definitionTextAsset.text);
}
/// <summary>
/// Clears all the definitions in the factory
/// </summary>
/// <remarks>
/// Does not reinitialize, please call <see cref="Initialize"/> to initialize it back
/// </remarks>
protected override void OnFactoryReset() => _definitions?.Clear();
/// <summary>
/// Manually registers a <see cref="MovementDefinition"/> to the factory with a JSON <see cref="string"/>
/// </summary>
@@ -81,14 +71,6 @@ namespace Syntriax.Modules.Movement.Config
AddDefinitionToFactory(movementDefinition);
}
/// <summary>
/// Clears all the definitions in the factory
/// </summary>
/// <remarks>
/// Does not reinitialize, please call <see cref="Initialize"/> to initialize it back
/// </remarks>
public void Reset() => _definitions?.Clear();
/// <summary>
/// Registers a list of <see cref="MovementDefinition"/>s to the factory
/// </summary>
@@ -118,7 +100,7 @@ namespace Syntriax.Modules.Movement.Config
public void ApplyDefinitionToGameObject(GameObject gameObject, string definitionName)
{
if (!Definitions.ContainsKey(definitionName))
throw new System.ArgumentException($"The definition with name \"{definitionName}\" does not exists in the current {Name}");
throw new System.ArgumentException($"The definition with name \"{definitionName}\" does not exists in the current {nameof(MovementDefinitionFactory)}");
ApplyDefinitionToGameObject(gameObject, Definitions[definitionName]);
}
@@ -132,13 +114,13 @@ namespace Syntriax.Modules.Movement.Config
{
foreach (MovementConfig movementConfig in definition.MovementConfigs)
{
IMovement movement = (IMovement)MovementFactory.Instance.AddToGameObject(gameObject, movementConfig.TypeName);
IMovement movement = (IMovement)FactorySingleton<MovementFactory>.Instance.AddToGameObject(gameObject, movementConfig.TypeName);
movement.BaseSpeed = movementConfig.BaseSpeed;
}
if (definition.MonoBehaviours != null)
foreach (string monoBehaviours in definition.MonoBehaviours)
MovementFactory.Instance.AddToGameObject(gameObject, monoBehaviours);
FactorySingleton<MovementFactory>.Instance.AddToGameObject(gameObject, monoBehaviours);
}
}
}

View File

@@ -2,38 +2,21 @@ using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using Syntriax.Modules.Factory;
using UnityEngine;
namespace Syntriax.Modules.Movement.Config
{
public class MovementFactory : MonoBehaviour
public class MovementFactory : FactoryBase
{
private const string Name = "Movement Factory";
private const int InitialCapacity = 64;
private static MovementFactory _instance = null;
public static MovementFactory Instance
{
get
{
if (_instance == null)
{
GameObject factoriesGO = GameObject.Find("Factories") ?? new GameObject("Factories");
_instance = new GameObject(Name).AddComponent<MovementFactory>();
_instance.transform.SetParent(factoriesGO.transform);
DontDestroyOnLoad(factoriesGO);
}
return _instance;
}
}
private Dictionary<string, Type> _types = null;
public Dictionary<string, Type> Types
{
get
{
if (_types == null)
if (!IsInitialized)
Initialize();
return _types;
@@ -44,45 +27,35 @@ namespace Syntriax.Modules.Movement.Config
private void Start()
{
if (_instance == this)
if (FactorySingleton<MovementFactory>.Instance == this)
return;
Destroy(this);
}
public void Initialize()
protected override void OnFactoryInitialize()
{
if (_types == null)
_types = new Dictionary<string, Type>(InitialCapacity);
Reset();
foreach (Assembly assembly in AppDomain.CurrentDomain.GetAssemblies())
AddAssemblyToFactory(assembly);
}
public void Reset() => _types?.Clear();
protected override void OnFactoryReset() => _types?.Clear();
public void AddAssemblyToFactory(Assembly assembly)
{
foreach (Type type in assembly.GetTypes().Where(predicate))
Types.Add(GetTypeName(type), type);
Types.Add(type.FullName, type);
}
public Component AddToGameObject(GameObject gameObject, string name)
{
if (!Types.ContainsKey(name))
throw new ArgumentException($"The key \"{name}\" does not exists in the current {Name}");
throw new ArgumentException($"The key \"{name}\" does not exists in the current {nameof(MovementFactory)}");
return gameObject.AddComponent(Types[name]);
}
public static string GetTypeName(Type type)
{
if (string.IsNullOrEmpty(type.Namespace))
return type.Name;
return $"{type.Namespace}.{type.Name}";
}
}
}

View File

@@ -1,7 +1,10 @@
using UnityEngine;
namespace Syntriax.Modules.Movement.Implementations
namespace Syntriax.Modules.Movement
{
/// <summary>
/// A <see cref="IMovement" with no implementation, added by <see cref="MovementController" by default as a fallback implementation/>/>
/// </summary>
public class DefaultMovement : MovementBase
{
public override void ApplyMovement() { }

View File

@@ -1,10 +1,16 @@
using System;
using System.Collections.Generic;
using Syntriax.Modules.State;
namespace Syntriax.Modules.Movement
{
public interface IMovementController
{
/// <summary>
/// <see cref="IStateEnable"/> to control the state of the <see cref="IMovementController"/> is on or off
/// </summary>
IStateEnable StateEnable { get; }
/// <summary>
/// Currently active <see cref="IMovement"/>
/// </summary>
@@ -27,6 +33,12 @@ namespace Syntriax.Modules.Movement
/// <value>Actived <see cref="IMovement"/></value>
Action<IMovement> OnMovementActivated { get; set; }
/// <summary>
/// Called when <see cref="Move"/> is called
/// </summary>
/// <value>The x, y, z values of <see cref="Move"/></value>
Action<float, float, float> OnMoveCalled { get; set; }
/// <summary>
/// Updates the <see cref="Movements"/> list
/// </summary>

View File

@@ -8,12 +8,12 @@ namespace Syntriax.Modules.Movement
/// Calls <see cref="IMovementController.Move"/> with a <see cref="Vector2"/>'s values accordingly, leaving the z parameter 0
/// </summary>
public static void Move(this IMovementController movementController, Vector2 moveVector)
=> movementController.ActiveMovement?.Move(moveVector.x, moveVector.y, 0f);
=> movementController.Move(moveVector.x, moveVector.y, 0f);
/// <summary>
/// Calls <see cref="IMovementController.Move"/> with a <see cref="Vector3"/>'s values accordingly
/// </summary>
public static void Move(this IMovementController movementController, Vector3 moveVector)
=> movementController.ActiveMovement?.Move(moveVector.x, moveVector.y, moveVector.z);
=> movementController.Move(moveVector.x, moveVector.y, moveVector.z);
}
}

View File

@@ -1,12 +1,14 @@
using System;
using System.Collections.Generic;
using Syntriax.Modules.ToggleState;
using Syntriax.Modules.State;
using UnityEngine;
namespace Syntriax.Modules.Movement
{
public class MovementController : MonoBehaviour, IMovementController
{
public Action<float, float, float> OnMoveCalled { get; set; } = null;
public Action<IMovement> OnMovementDeactivated { get; set; } = null;
public Action<IMovement> OnMovementActivated { get; set; } = null;
@@ -29,25 +31,32 @@ namespace Syntriax.Modules.Movement
}
}
public List<IMovement> Movements { get; protected set; } = null;
public List<IMovement> Movements { get; protected set; } = new List<IMovement>(32);
protected IToggleState toggleState = null;
protected virtual void Awake()
=> Movements = new List<IMovement>(32);
private IStateEnable _stateEnable = null;
public IStateEnable StateEnable
{
get
{
_stateEnable = _stateEnable ?? GetComponent<State.IStateEnable>() ?? gameObject.AddComponent<State.StateEnableMonoBehaviour>();
return _stateEnable;
}
}
protected virtual void Start()
{
if (GetComponent<Implementations.DefaultMovement>() == null)
gameObject.AddComponent<Implementations.DefaultMovement>();
if (GetComponent<DefaultMovement>() == null)
gameObject.AddComponent<DefaultMovement>();
RecacheMovements();
toggleState = GetComponent<IToggleState>();
StateEnable.OnEnabledChanged += (_) => InvokeOnMoveAction();
OnMovementActivated += (newMovement) => newMovement.Move(lastMove);
}
protected virtual void FixedUpdate()
{
if (!toggleState.IsToggledNullChecked())
if (!StateEnable.IsEnabledNullChecked())
return;
ActiveMovement?.ApplyMovement();
@@ -78,7 +87,22 @@ namespace Syntriax.Modules.Movement
}
}
private Vector3 lastMove = Vector3.zero;
public void Move(float x = 0, float y = 0, float z = 0)
=> ActiveMovement?.Move(x, y, z);
{
ActiveMovement?.Move(x, y, z);
(lastMove.x, lastMove.y, lastMove.z) = (x, y, z);
InvokeOnMoveAction();
}
private void InvokeOnMoveAction()
{
if (!StateEnable.IsEnabledNullChecked())
return;
OnMoveCalled?.Invoke(lastMove.x, lastMove.y, lastMove.z);
}
}
}

View File

@@ -1,4 +1,5 @@
using System;
using Syntriax.Modules.Factory;
using Syntriax.Modules.Movement.Config;
using UnityEngine;
@@ -25,7 +26,7 @@ namespace Syntriax.Modules.Movement
{
RemoveDefinition();
MovementDefinitionFactory.Instance.ApplyDefinitionToGameObject(gameObject, definitionName);
FactorySingleton<MovementDefinitionFactory>.Instance.ApplyDefinitionToGameObject(gameObject, definitionName);
appliedDefinitionName = definitionName;
OnMovementDefinitionApplied?.Invoke(gameObject);
}
@@ -34,7 +35,7 @@ namespace Syntriax.Modules.Movement
{
RemoveDefinition();
MovementDefinitionFactory.Instance.ApplyDefinitionToGameObject(gameObject, definition);
FactorySingleton<MovementDefinitionFactory>.Instance.ApplyDefinitionToGameObject(gameObject, definition);
appliedDefinitionName = definition.Name;
OnMovementDefinitionApplied?.Invoke(gameObject);
}
@@ -44,20 +45,20 @@ namespace Syntriax.Modules.Movement
if (string.IsNullOrWhiteSpace(appliedDefinitionName))
return;
MovementDefinition appliedDefinition = MovementDefinitionFactory.Instance.Definitions[appliedDefinitionName];
MovementDefinition appliedDefinition = FactorySingleton<MovementDefinitionFactory>.Instance.Definitions[appliedDefinitionName];
if (appliedDefinition.MovementConfigs == null || appliedDefinition.MonoBehaviours == null)
return;
foreach (MovementConfig movementConfig in appliedDefinition.MovementConfigs)
{
Type type = MovementFactory.Instance.Types[movementConfig.TypeName];
Type type = FactorySingleton<MovementFactory>.Instance.Types[movementConfig.TypeName];
if (TryGetComponent(type, out Component component))
Destroy(component);
}
foreach (string monoBehaviour in appliedDefinition.MonoBehaviours)
{
Type type = MovementFactory.Instance.Types[monoBehaviour];
Type type = FactorySingleton<MovementFactory>.Instance.Types[monoBehaviour];
if (TryGetComponent(type, out Component component))
Destroy(component);
}

View File

@@ -2,9 +2,9 @@
"name": "Syntriax.Modules.Movement",
"rootNamespace": "",
"references": [
"GUID:75469ad4d38634e559750d17036d5f7c",
"GUID:efa9a9bc94c60c74684aafb7428fbf61",
"GUID:1f5f15fe7e49bdb48a76c5ce9b1c9f2f"
"GUID:1f5f15fe7e49bdb48a76c5ce9b1c9f2f",
"GUID:d4c952ed5f59c5a449cda1b0080ed841"
],
"includePlatforms": [],
"excludePlatforms": [],

View File

@@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: 6756a6e4e4a43f340b4ce48f3adb3038
guid: 231b2d16dd7862d41bc2111d759f6ca2
folderAsset: yes
DefaultImporter:
externalObjects: {}

View File

@@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: 15528ebd51d27d54398c55826710f23e
guid: 65b5d2a8df8888642939b2395c63a554
folderAsset: yes
DefaultImporter:
externalObjects: {}

8
Samples/2D/Scene.meta Normal file
View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 1b2acded463f8444cb723331931d27c2
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,636 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!29 &1
OcclusionCullingSettings:
m_ObjectHideFlags: 0
serializedVersion: 2
m_OcclusionBakeSettings:
smallestOccluder: 5
smallestHole: 0.25
backfaceThreshold: 100
m_SceneGUID: 00000000000000000000000000000000
m_OcclusionCullingData: {fileID: 0}
--- !u!104 &2
RenderSettings:
m_ObjectHideFlags: 0
serializedVersion: 9
m_Fog: 0
m_FogColor: {r: 0.5, g: 0.5, b: 0.5, a: 1}
m_FogMode: 3
m_FogDensity: 0.01
m_LinearFogStart: 0
m_LinearFogEnd: 300
m_AmbientSkyColor: {r: 0.212, g: 0.227, b: 0.259, a: 1}
m_AmbientEquatorColor: {r: 0.114, g: 0.125, b: 0.133, a: 1}
m_AmbientGroundColor: {r: 0.047, g: 0.043, b: 0.035, a: 1}
m_AmbientIntensity: 1
m_AmbientMode: 3
m_SubtractiveShadowColor: {r: 0.42, g: 0.478, b: 0.627, a: 1}
m_SkyboxMaterial: {fileID: 0}
m_HaloStrength: 0.5
m_FlareStrength: 1
m_FlareFadeSpeed: 3
m_HaloTexture: {fileID: 0}
m_SpotCookie: {fileID: 10001, guid: 0000000000000000e000000000000000, type: 0}
m_DefaultReflectionMode: 0
m_DefaultReflectionResolution: 128
m_ReflectionBounces: 1
m_ReflectionIntensity: 1
m_CustomReflection: {fileID: 0}
m_Sun: {fileID: 0}
m_IndirectSpecularColor: {r: 0, g: 0, b: 0, a: 1}
m_UseRadianceAmbientProbe: 0
--- !u!157 &3
LightmapSettings:
m_ObjectHideFlags: 0
serializedVersion: 12
m_GIWorkflowMode: 1
m_GISettings:
serializedVersion: 2
m_BounceScale: 1
m_IndirectOutputScale: 1
m_AlbedoBoost: 1
m_EnvironmentLightingMode: 0
m_EnableBakedLightmaps: 0
m_EnableRealtimeLightmaps: 0
m_LightmapEditorSettings:
serializedVersion: 12
m_Resolution: 2
m_BakeResolution: 40
m_AtlasSize: 1024
m_AO: 0
m_AOMaxDistance: 1
m_CompAOExponent: 1
m_CompAOExponentDirect: 0
m_ExtractAmbientOcclusion: 0
m_Padding: 2
m_LightmapParameters: {fileID: 0}
m_LightmapsBakeMode: 1
m_TextureCompression: 1
m_FinalGather: 0
m_FinalGatherFiltering: 1
m_FinalGatherRayCount: 256
m_ReflectionCompression: 2
m_MixedBakeMode: 2
m_BakeBackend: 1
m_PVRSampling: 1
m_PVRDirectSampleCount: 32
m_PVRSampleCount: 512
m_PVRBounces: 2
m_PVREnvironmentSampleCount: 256
m_PVREnvironmentReferencePointCount: 2048
m_PVRFilteringMode: 1
m_PVRDenoiserTypeDirect: 1
m_PVRDenoiserTypeIndirect: 1
m_PVRDenoiserTypeAO: 1
m_PVRFilterTypeDirect: 0
m_PVRFilterTypeIndirect: 0
m_PVRFilterTypeAO: 0
m_PVREnvironmentMIS: 1
m_PVRCulling: 1
m_PVRFilteringGaussRadiusDirect: 1
m_PVRFilteringGaussRadiusIndirect: 5
m_PVRFilteringGaussRadiusAO: 2
m_PVRFilteringAtrousPositionSigmaDirect: 0.5
m_PVRFilteringAtrousPositionSigmaIndirect: 2
m_PVRFilteringAtrousPositionSigmaAO: 1
m_ExportTrainingData: 0
m_TrainingDataDestination: TrainingData
m_LightProbeSampleCountMultiplier: 4
m_LightingDataAsset: {fileID: 0}
m_LightingSettings: {fileID: 0}
--- !u!196 &4
NavMeshSettings:
serializedVersion: 2
m_ObjectHideFlags: 0
m_BuildSettings:
serializedVersion: 2
agentTypeID: 0
agentRadius: 0.5
agentHeight: 2
agentSlope: 45
agentClimb: 0.4
ledgeDropHeight: 0
maxJumpAcrossDistance: 0
minRegionArea: 2
manualCellSize: 0
cellSize: 0.16666667
manualTileSize: 0
tileSize: 256
accuratePlacement: 0
maxJobWorkers: 0
preserveTilesOutsideBounds: 0
debug:
m_Flags: 0
m_NavMeshData: {fileID: 0}
--- !u!1 &221828166
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 221828172}
- component: {fileID: 221828169}
- component: {fileID: 221828170}
- component: {fileID: 221828168}
- component: {fileID: 221828167}
- component: {fileID: 221828173}
m_Layer: 0
m_Name: Player
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!114 &221828167
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 221828166}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 10b59caf08f3e2d4b94eb72b7885346d, type: 3}
m_Name:
m_EditorClassIdentifier:
_baseSpeed: 5
_movementMultiplier: 1
--- !u!114 &221828168
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 221828166}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 69ca5998eb951b64499b111100275018, type: 3}
m_Name:
m_EditorClassIdentifier:
_baseSpeed: 1
_movementMultiplier: 1
--- !u!50 &221828169
Rigidbody2D:
serializedVersion: 4
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 221828166}
m_BodyType: 0
m_Simulated: 1
m_UseFullKinematicContacts: 0
m_UseAutoMass: 0
m_Mass: 1
m_LinearDrag: 0
m_AngularDrag: 0.05
m_GravityScale: 1
m_Material: {fileID: 0}
m_Interpolate: 0
m_SleepingMode: 1
m_CollisionDetection: 0
m_Constraints: 0
--- !u!114 &221828170
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 221828166}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: e5a74cc1b761aae448c854eb652fcc13, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!4 &221828172
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 221828166}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 2, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children:
- {fileID: 332317891}
- {fileID: 924263135}
m_Father: {fileID: 0}
m_RootOrder: 2
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &221828173
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 221828166}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: c3737b1292e46ab4ba2a2c139a8c2ef2, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!1 &332317890
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 332317891}
- component: {fileID: 332317893}
- component: {fileID: 332317892}
m_Layer: 0
m_Name: Square
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &332317891
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 332317890}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 221828172}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!61 &332317892
BoxCollider2D:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 332317890}
m_Enabled: 1
m_Density: 1
m_Material: {fileID: 0}
m_IsTrigger: 0
m_UsedByEffector: 0
m_UsedByComposite: 0
m_Offset: {x: 0, y: 0}
m_SpriteTilingProperty:
border: {x: 0, y: 0, z: 0, w: 0}
pivot: {x: 0.5, y: 0.5}
oldSize: {x: 1, y: 1}
newSize: {x: 1, y: 1}
adaptiveTilingThreshold: 0.5
drawMode: 0
adaptiveTiling: 0
m_AutoTiling: 0
serializedVersion: 2
m_Size: {x: 1, y: 1}
m_EdgeRadius: 0
--- !u!212 &332317893
SpriteRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 332317890}
m_Enabled: 1
m_CastShadows: 0
m_ReceiveShadows: 0
m_DynamicOccludee: 1
m_StaticShadowCaster: 0
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_RayTracingMode: 0
m_RayTraceProcedural: 0
m_RenderingLayerMask: 1
m_RendererPriority: 0
m_Materials:
- {fileID: 2100000, guid: a97c105638bdf8b4a8650670310a4cd3, type: 2}
m_StaticBatchInfo:
firstSubMesh: 0
subMeshCount: 0
m_StaticBatchRoot: {fileID: 0}
m_ProbeAnchor: {fileID: 0}
m_LightProbeVolumeOverride: {fileID: 0}
m_ScaleInLightmap: 1
m_ReceiveGI: 1
m_PreserveUVs: 0
m_IgnoreNormalsForChartDetection: 0
m_ImportantGI: 0
m_StitchLightmapSeams: 1
m_SelectedEditorRenderState: 0
m_MinimumChartSize: 4
m_AutoUVMaxDistance: 0.5
m_AutoUVMaxAngle: 89
m_LightmapParameters: {fileID: 0}
m_SortingLayerID: 0
m_SortingLayer: 0
m_SortingOrder: 0
m_Sprite: {fileID: 7482667652216324306, guid: 311925a002f4447b3a28927169b83ea6, type: 3}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_FlipX: 0
m_FlipY: 0
m_DrawMode: 0
m_Size: {x: 1, y: 1}
m_AdaptiveModeThreshold: 0.5
m_SpriteTileMode: 0
m_WasSpriteAssigned: 1
m_MaskInteraction: 0
m_SpriteSortPoint: 0
--- !u!1 &756791934
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 756791938}
- component: {fileID: 756791937}
- component: {fileID: 756791936}
- component: {fileID: 756791935}
m_Layer: 0
m_Name: Camera
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!114 &756791935
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 756791934}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: a79441f348de89743a2939f4d699eac1, type: 3}
m_Name:
m_EditorClassIdentifier:
m_RenderShadows: 1
m_RequiresDepthTextureOption: 2
m_RequiresOpaqueTextureOption: 2
m_CameraType: 0
m_Cameras: []
m_RendererIndex: -1
m_VolumeLayerMask:
serializedVersion: 2
m_Bits: 1
m_VolumeTrigger: {fileID: 0}
m_VolumeFrameworkUpdateModeOption: 2
m_RenderPostProcessing: 0
m_Antialiasing: 0
m_AntialiasingQuality: 2
m_StopNaN: 0
m_Dithering: 0
m_ClearDepth: 1
m_AllowXRRendering: 1
m_RequiresDepthTexture: 0
m_RequiresColorTexture: 0
m_Version: 2
--- !u!81 &756791936
AudioListener:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 756791934}
m_Enabled: 1
--- !u!20 &756791937
Camera:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 756791934}
m_Enabled: 1
serializedVersion: 2
m_ClearFlags: 1
m_BackGroundColor: {r: 0.19215687, g: 0.3019608, b: 0.4745098, a: 0}
m_projectionMatrixMode: 1
m_GateFitMode: 2
m_FOVAxisMode: 0
m_SensorSize: {x: 36, y: 24}
m_LensShift: {x: 0, y: 0}
m_FocalLength: 50
m_NormalizedViewPortRect:
serializedVersion: 2
x: 0
y: 0
width: 1
height: 1
near clip plane: 0.3
far clip plane: 1000
field of view: 60
orthographic: 1
orthographic size: 5
m_Depth: 0
m_CullingMask:
serializedVersion: 2
m_Bits: 4294967295
m_RenderingPath: -1
m_TargetTexture: {fileID: 0}
m_TargetDisplay: 0
m_TargetEye: 3
m_HDR: 1
m_AllowMSAA: 1
m_AllowDynamicResolution: 0
m_ForceIntoRT: 0
m_OcclusionCulling: 1
m_StereoConvergence: 10
m_StereoSeparation: 0.022
--- !u!4 &756791938
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 756791934}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: -10}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &783353104
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 783353107}
- component: {fileID: 783353106}
- component: {fileID: 783353105}
m_Layer: 0
m_Name: Square
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 2147483647
m_IsActive: 1
--- !u!61 &783353105
BoxCollider2D:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 783353104}
m_Enabled: 1
m_Density: 1
m_Material: {fileID: 0}
m_IsTrigger: 0
m_UsedByEffector: 0
m_UsedByComposite: 0
m_Offset: {x: 0, y: 0}
m_SpriteTilingProperty:
border: {x: 0, y: 0, z: 0, w: 0}
pivot: {x: 0.5, y: 0.5}
oldSize: {x: 1, y: 1}
newSize: {x: 1, y: 1}
adaptiveTilingThreshold: 0.5
drawMode: 0
adaptiveTiling: 0
m_AutoTiling: 0
serializedVersion: 2
m_Size: {x: 1, y: 1}
m_EdgeRadius: 0
--- !u!212 &783353106
SpriteRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 783353104}
m_Enabled: 1
m_CastShadows: 0
m_ReceiveShadows: 0
m_DynamicOccludee: 1
m_StaticShadowCaster: 0
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_RayTracingMode: 0
m_RayTraceProcedural: 0
m_RenderingLayerMask: 1
m_RendererPriority: 0
m_Materials:
- {fileID: 2100000, guid: a97c105638bdf8b4a8650670310a4cd3, type: 2}
m_StaticBatchInfo:
firstSubMesh: 0
subMeshCount: 0
m_StaticBatchRoot: {fileID: 0}
m_ProbeAnchor: {fileID: 0}
m_LightProbeVolumeOverride: {fileID: 0}
m_ScaleInLightmap: 1
m_ReceiveGI: 1
m_PreserveUVs: 0
m_IgnoreNormalsForChartDetection: 0
m_ImportantGI: 0
m_StitchLightmapSeams: 1
m_SelectedEditorRenderState: 0
m_MinimumChartSize: 4
m_AutoUVMaxDistance: 0.5
m_AutoUVMaxAngle: 89
m_LightmapParameters: {fileID: 0}
m_SortingLayerID: 0
m_SortingLayer: 0
m_SortingOrder: 0
m_Sprite: {fileID: 7482667652216324306, guid: 311925a002f4447b3a28927169b83ea6, type: 3}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_FlipX: 0
m_FlipY: 0
m_DrawMode: 0
m_Size: {x: 1, y: 1}
m_AdaptiveModeThreshold: 0.5
m_SpriteTileMode: 0
m_WasSpriteAssigned: 1
m_MaskInteraction: 0
m_SpriteSortPoint: 0
--- !u!4 &783353107
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 783353104}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 10, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &924263134
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 924263135}
- component: {fileID: 924263136}
- component: {fileID: 924263137}
m_Layer: 0
m_Name: Ground
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &924263135
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 924263134}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: -0.65, z: 0}
m_LocalScale: {x: 1, y: 0.2, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 221828172}
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &924263136
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 924263134}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 4b3db9faa3a5e9f4db37172c452dbf2a, type: 3}
m_Name:
m_EditorClassIdentifier:
colliderMask:
serializedVersion: 2
m_Bits: 4294967295
--- !u!114 &924263137
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 924263134}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 91a5b9cf888de6f4da572ac875fc826c, type: 3}
m_Name:
m_EditorClassIdentifier:

View File

@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: cb7dbd426de18f54c9df9922768b1a6f
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

8
Samples/2D/Scripts.meta Normal file
View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 53fb73867b202d4438ab1213be0e9ce2
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,7 +1,7 @@
using Syntriax.Modules.Trigger;
using UnityEngine;
namespace Syntriax.Modules.Movement.Implementations
namespace Syntriax.Modules.Movement.Samples
{
[RequireComponent(typeof(Rigidbody2D))]
public class AirMovement1D : MovementBase1D
@@ -14,12 +14,12 @@ namespace Syntriax.Modules.Movement.Implementations
{
base.Start();
rigid = GetComponent<Rigidbody2D>();
rigid = GetComponentInParent<Rigidbody2D>();
groundTrigger = GetComponentInChildren<IGroundTrigger>();
if (groundTrigger != null)
{
groundTrigger.OnTriggered += OnGroundTrigger;
groundTrigger.OnTriggerStateChanged += OnGroundTrigger;
CanTakeOver = false;
}
}
@@ -33,12 +33,8 @@ namespace Syntriax.Modules.Movement.Implementations
velocity.x += moveValue * Time.fixedDeltaTime;
if (moveValue != 0f)
{
if (Mathf.Abs(velocity.x) > Mathf.Abs(moveValue))
velocity.x = moveValue;
else if (Mathf.Abs(velocity.x - moveValue) > Mathf.Abs(moveValue))
velocity.x += moveValue * Time.fixedDeltaTime;
}
velocity.x *= .95f;
rigid.velocity = velocity;
}

View File

@@ -1,8 +1,9 @@
using Syntriax.Modules.Trigger;
using UnityEngine;
namespace Syntriax.Modules.Movement.Implementations
namespace Syntriax.Modules.Movement.Samples
{
[System.Serializable]
[RequireComponent(typeof(Rigidbody2D))]
public class GroundMovement1D : MovementBase1D
{
@@ -16,12 +17,12 @@ namespace Syntriax.Modules.Movement.Implementations
{
base.Start();
rigid = GetComponent<Rigidbody2D>();
rigid = GetComponentInParent<Rigidbody2D>();
groundTrigger = GetComponentInChildren<IGroundTrigger>();
if (groundTrigger != null)
{
groundTrigger.OnTriggered += OnGroundTrigger;
groundTrigger.OnTriggerStateChanged += OnGroundTrigger;
CanTakeOver = false;
}
}

View File

@@ -0,0 +1,40 @@
using System;
using Syntriax.Modules.Trigger;
using UnityEngine;
namespace Syntriax.Modules.Movement.Samples
{
public class MovementInputSample : MonoBehaviour
{
private IMovementController movementController = null;
private Rigidbody2D rigid = null;
private IGroundTrigger groundTrigger = null;
private void Start()
{
movementController = GetComponent<IMovementController>();
groundTrigger = GetComponentInChildren<IGroundTrigger>();
rigid = GetComponent<Rigidbody2D>();
}
private Vector3 input = Vector3.zero;
private void Update()
{
input = Vector3.zero;
input.x = Input.GetAxis("Horizontal");
input.y = Input.GetAxis("Vertical");
movementController.Move(input);
if (Input.GetKeyDown(KeyCode.Space) && groundTrigger.IsTrigerred)
Jump();
}
private void Jump()
{
Vector2 velocity = rigid.velocity;
velocity.y = 10f;
rigid.velocity = velocity;
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: c3737b1292e46ab4ba2a2c139a8c2ef2
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,19 @@
{
"name": "Syntriax.Modules.Movement.Samples",
"rootNamespace": "",
"references": [
"GUID:efa9a9bc94c60c74684aafb7428fbf61",
"GUID:1f5f15fe7e49bdb48a76c5ce9b1c9f2f",
"GUID:d4c952ed5f59c5a449cda1b0080ed841",
"GUID:c967acc4be781ca44b42a1887eb1ac7a"
],
"includePlatforms": [],
"excludePlatforms": [],
"allowUnsafeCode": false,
"overrideReferences": false,
"precompiledReferences": [],
"autoReferenced": true,
"defineConstraints": [],
"versionDefines": [],
"noEngineReferences": false
}

View File

@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 863b8995abde2cf40b8b4cb709452a32
AssemblyDefinitionImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

Submodule ToggleState deleted from 6afed7407d

Submodule Trigger deleted from dabe16b529

14
package.json Normal file
View File

@@ -0,0 +1,14 @@
{
"name": "com.syntriax.movement",
"version": "0.2.0",
"displayName": "Movement Module",
"description": "Dependends On:\nhttps://git.syntriax.com/Syntriax/State.git\nhttps://git.syntriax.com/Syntriax/Trigger.git\nhttps://git.syntriax.com/Syntriax/Factory.git",
"unity": "2019.1",
"documentationUrl": "https://git.syntriax.com/Syntriax/Movement.git",
"keywords": ["Movement"],
"author": {
"name": "Syntriax",
"email": "Syntriax@gmail.com",
"url": "https://syntriax.com"
}
}

7
package.json.meta Normal file
View File

@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: bc3fcd495f9be6c4ca16b16a8ea637ac
TextScriptImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant: