init
This commit is contained in:
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8bf7e79f48a548eb84e276eee5e5e625
|
||||
timeCreated: 1774105234
|
||||
@@ -0,0 +1,29 @@
|
||||
using RPGCore.BackpackEquipment.ObjectModules.UnitEquipment.Objects;
|
||||
using RPGCore.ObjectModules.ActionObjectModule;
|
||||
|
||||
namespace RPGCore.BackpackEquipment.ObjectModules.UnitEquipment.Actions
|
||||
{
|
||||
public class EquipAction : BaseAction
|
||||
{
|
||||
private readonly WearableObject _wearable;
|
||||
private readonly int _index;
|
||||
|
||||
public EquipAction(WearableObject wearable, int index = -1)
|
||||
{
|
||||
_wearable = wearable;
|
||||
_index = index;
|
||||
}
|
||||
|
||||
public override void CanDoIt()
|
||||
{
|
||||
}
|
||||
|
||||
protected override void OnDoIt()
|
||||
{
|
||||
}
|
||||
|
||||
protected override void OnEndIt() { }
|
||||
|
||||
protected override void OnCancelIt() { }
|
||||
}
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e7e7ce4fbec54ebfbe05f9cecae4a871
|
||||
timeCreated: 1774105374
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
using RPGCore.ObjectModules.ActionObjectModule;
|
||||
|
||||
namespace RPGCore.BackpackEquipment.ObjectModules.UnitEquipment.Actions
|
||||
{
|
||||
public class UnEquipAction : BaseAction
|
||||
{
|
||||
public override void CanDoIt()
|
||||
{
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
protected override void OnDoIt()
|
||||
{
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
protected override void OnEndIt()
|
||||
{
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
protected override void OnCancelIt()
|
||||
{
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 48179d58af5844cb9ea6d3df49a151cb
|
||||
timeCreated: 1774105416
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8935ac7ea78145d2bade1ab807dcf5ac
|
||||
timeCreated: 1776013837
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
using System;
|
||||
using RPGCore.BackpackEquipment.ObjectModules.UnitEquipment.Objects;
|
||||
using RPGCore.Core.Objects;
|
||||
using RPGCore.ObjectModules.EventObjectModule;
|
||||
using RPGCoreCommon.Helpers.PropertyAttributeDrawers;
|
||||
using UnityEngine;
|
||||
|
||||
namespace RPGCore.BackpackEquipment.ObjectModules.UnitEquipment.Data
|
||||
{
|
||||
[Serializable]
|
||||
public sealed class WearableObjectData : BaseData<WearableObject>
|
||||
{
|
||||
[Header("Current state")]
|
||||
[field: SerializeField, ReadOnly] public UnitObject equippedBy { get; set; }
|
||||
|
||||
[Header("WEARABLE")]
|
||||
[field: SerializeField] public WearableTypeSO type { get; private set; }
|
||||
}
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5225f7b9b3fd4b15874ed6af5a887703
|
||||
timeCreated: 1775931397
|
||||
@@ -0,0 +1,10 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace RPGCore.BackpackEquipment.ObjectModules.UnitEquipment
|
||||
{
|
||||
[CreateAssetMenu(menuName = "RPG Core/Equipment/Schema")]
|
||||
public class EquipmentSchemaSO : ScriptableObject
|
||||
{
|
||||
public EquipmentSchemaSlot[] slots;
|
||||
}
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1b6db097519240cdb57eb1a235eb6d00
|
||||
timeCreated: 1774117121
|
||||
@@ -0,0 +1,14 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace RPGCore.BackpackEquipment.ObjectModules.UnitEquipment
|
||||
{
|
||||
[Serializable]
|
||||
public class EquipmentSchemaSlot
|
||||
{
|
||||
public string name;
|
||||
public Texture2D icon;
|
||||
public List<WearableTypeSO> validTypes;
|
||||
}
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3c100a156e9e403888cab30f01b22b2e
|
||||
timeCreated: 1774117160
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5a9185f4f6844784b7432d9353365f7f
|
||||
timeCreated: 1774105234
|
||||
@@ -0,0 +1,14 @@
|
||||
using RPGCore.BackpackEquipment.ObjectModules.UnitEquipment.Objects;
|
||||
using RPGCore.BackpackEquipment.Objects;
|
||||
using RPGCore.Core.Objects;
|
||||
using RPGCore.ObjectModules.EventObjectModule;
|
||||
|
||||
namespace RPGCore.BackpackEquipment.ObjectModules.UnitEquipment.Events
|
||||
{
|
||||
public class EquipEvent : BaseEvent<UnitObject>
|
||||
{
|
||||
public UnitObject unit;
|
||||
public WearableObject wearable;
|
||||
public int index;
|
||||
}
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9c3da958a57e4b019de195f87cc032d7
|
||||
timeCreated: 1774105477
|
||||
@@ -0,0 +1,14 @@
|
||||
using RPGCore.BackpackEquipment.ObjectModules.UnitEquipment.Objects;
|
||||
using RPGCore.BackpackEquipment.Objects;
|
||||
using RPGCore.Core.Objects;
|
||||
using RPGCore.ObjectModules.EventObjectModule;
|
||||
|
||||
namespace RPGCore.BackpackEquipment.ObjectModules.UnitEquipment.Events
|
||||
{
|
||||
public class UnEquipEvent : BaseEvent<UnitObject>
|
||||
{
|
||||
public UnitObject unit;
|
||||
public WearableObject wearable;
|
||||
public int index;
|
||||
}
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b9b6c7062a844cb6bf556d76e7351410
|
||||
timeCreated: 1774105488
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4f78116570fd4167a06bb18e9f0d585b
|
||||
timeCreated: 1776013778
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
using System;
|
||||
using RPGCore.BackpackEquipment.Objects;
|
||||
using RPGCore.Core;
|
||||
using RPGCoreCommon.DynamicValues;
|
||||
|
||||
namespace RPGCore.BackpackEquipment.ObjectModules.UnitEquipment.Objects
|
||||
{
|
||||
public class WearableObject : ItemObject
|
||||
{
|
||||
[DynamicValueProvider]
|
||||
private ObjectModule<WearableObject> UsableModuleProvider(Type moduleType) => GetComponent(moduleType) as ObjectModule<WearableObject>;
|
||||
}
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c2ef6b5eaa38431bacb28adb8bb2739c
|
||||
timeCreated: 1773430452
|
||||
@@ -0,0 +1,78 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using RPGCore.BackpackEquipment.ObjectModules.Content;
|
||||
using RPGCore.BackpackEquipment.ObjectModules.UnitEquipment.Data;
|
||||
using RPGCore.BackpackEquipment.ObjectModules.UnitEquipment.Events;
|
||||
using RPGCore.BackpackEquipment.ObjectModules.UnitEquipment.Objects;
|
||||
using RPGCore.BackpackEquipment.Objects;
|
||||
using RPGCore.Core;
|
||||
using RPGCore.Core.Objects;
|
||||
using UnityEngine;
|
||||
|
||||
namespace RPGCore.BackpackEquipment.ObjectModules.UnitEquipment
|
||||
{
|
||||
[RequireComponent(typeof(UnitObject))]
|
||||
[RequireComponent(typeof(ContentModule))]
|
||||
[DisallowMultipleComponent]
|
||||
public class UnitEquipmentModule : ObjectModule<UnitObject>, IContentOwner
|
||||
{
|
||||
[SerializeField] private EquipmentSchemaSO _schema;
|
||||
[SerializeField] private WearableObject[] _serializedItems;
|
||||
|
||||
private WearableObject[] _items;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
_items = new WearableObject[_schema.slots.Length];
|
||||
}
|
||||
|
||||
private void Start()
|
||||
{
|
||||
InitializeItems();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
private void InitializeItems()
|
||||
{
|
||||
// TODO: inicjalizacja serializowanych itemkow + ich eventy
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
public bool CanAdd(ItemObject item, int index)
|
||||
{
|
||||
if (item is not WearableObject wearable) return false;
|
||||
|
||||
var slot = _schema.slots[index];
|
||||
if (slot == null) return false;
|
||||
|
||||
if (!slot.validTypes.Contains(wearable.data.Get<WearableObjectData>().type)) return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool IContentOwner.Add(ItemObject item, int index)
|
||||
{
|
||||
var wearable = (WearableObject)item;
|
||||
|
||||
parent.events.Invoke(new EquipEvent { unit = parent, wearable = wearable, index = index });
|
||||
|
||||
_items[index] = wearable;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool IContentOwner.Remove(ItemObject item)
|
||||
{
|
||||
var wearable = (WearableObject)item;
|
||||
var index = Array.IndexOf(_items, wearable);
|
||||
|
||||
parent.events.Invoke(new UnEquipEvent { unit = parent, wearable = wearable, index = index });
|
||||
|
||||
_items[index] = null;
|
||||
return true;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
}
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2daf6192d70b4fc798983932b68c28ea
|
||||
timeCreated: 1773430702
|
||||
@@ -0,0 +1,12 @@
|
||||
using RPGCoreCommon.Helpers.CustomTypes;
|
||||
using UnityEngine;
|
||||
|
||||
namespace RPGCore.BackpackEquipment.ObjectModules.UnitEquipment
|
||||
{
|
||||
[CreateAssetMenu(menuName = "RPG Core/Equipment/Wearable Type")]
|
||||
public class WearableTypeSO : ScriptableObject
|
||||
{
|
||||
public new string name;
|
||||
public Texture2D icon;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2c0e3d78b2374dfbb1b254cb9a9cef19
|
||||
timeCreated: 1774116782
|
||||
Reference in New Issue
Block a user