1
This commit is contained in:
26
Assets/Artists/Scripts/Placement/AssetablePlacement.cs
Normal file
26
Assets/Artists/Scripts/Placement/AssetablePlacement.cs
Normal file
@@ -0,0 +1,26 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using BITKit;
|
||||
using Unity.Mathematics;
|
||||
using UnityEngine;
|
||||
|
||||
namespace BITFALL.Placement
|
||||
{
|
||||
[Serializable]
|
||||
public class IsPlaceable:IProperty
|
||||
{
|
||||
[SerializeField] private UnityPlacementObject placementObject;
|
||||
public IPlacementObject PlacementObject => placementObject;
|
||||
}
|
||||
public class AssetablePlacement : AssetableItem,IPlacementObject
|
||||
{
|
||||
[SerializeField] private UnityPlacementObject placementObject;
|
||||
public IPlacementObject Object => placementObject;
|
||||
public float PositionIncrement => Object.PositionIncrement;
|
||||
public int RotationIncrement => Object.RotationIncrement;
|
||||
public int3 Size=>placementObject.Size;
|
||||
public IPlacementObject CreateInstance() => Instantiate(placementObject);
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"name": "BITFALL.Placement.Runtime",
|
||||
"rootNamespace": "",
|
||||
"references": [
|
||||
"GUID:14fe60d984bf9f84eac55c6ea033a8f4",
|
||||
"GUID:87bea3a21c744b1478660b70494160ba",
|
||||
"GUID:a83bfc00a1ad8e74981b456e6c50ed4e",
|
||||
"GUID:d525ad6bd40672747bde77962f1c401e",
|
||||
"GUID:49b49c76ee64f6b41bf28ef951cb0e50",
|
||||
"GUID:677cd05ca06c46b4395470200b1acdad",
|
||||
"GUID:30cdc242b1ac6a944a460f4ab0b77b88",
|
||||
"GUID:d8b63aba1907145bea998dd612889d6b"
|
||||
],
|
||||
"includePlatforms": [],
|
||||
"excludePlatforms": [],
|
||||
"allowUnsafeCode": false,
|
||||
"overrideReferences": false,
|
||||
"precompiledReferences": [],
|
||||
"autoReferenced": true,
|
||||
"defineConstraints": [],
|
||||
"versionDefines": [],
|
||||
"noEngineReferences": false
|
||||
}
|
20
Assets/Artists/Scripts/Placement/UnityPlacementObject.cs
Normal file
20
Assets/Artists/Scripts/Placement/UnityPlacementObject.cs
Normal file
@@ -0,0 +1,20 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Unity.Mathematics;
|
||||
using UnityEngine;
|
||||
|
||||
namespace BITFALL.Placement
|
||||
{
|
||||
public class UnityPlacementObject : MonoBehaviour,IPlacementObject
|
||||
{
|
||||
[SerializeField] private int3 size;
|
||||
[SerializeField] private float positionIncrement = 1;
|
||||
[SerializeField] private int rotationIncrement = 15;
|
||||
public float PositionIncrement => positionIncrement;
|
||||
public int RotationIncrement => rotationIncrement;
|
||||
public int3 Size => size;
|
||||
public IPlacementObject CreateInstance()=>
|
||||
Instantiate(this);
|
||||
}
|
||||
|
||||
}
|
28
Assets/Artists/Scripts/Placement/UnityPlacementService.cs
Normal file
28
Assets/Artists/Scripts/Placement/UnityPlacementService.cs
Normal file
@@ -0,0 +1,28 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using UnityEngine;
|
||||
|
||||
namespace BITFALL.Placement
|
||||
{
|
||||
[Serializable]
|
||||
public sealed class UnityPlacementServiceSingleton:PlacementServiceImplementation
|
||||
{
|
||||
protected override IPlacementService _placementServiceImplementation => UnityPlacementService.Singleton;
|
||||
}
|
||||
public class UnityPlacementService : MonoBehaviour,IPlacementService
|
||||
{
|
||||
public static IPlacementService Singleton { get; private set; }
|
||||
|
||||
[SerializeField] private UnityPlacementObject[] placementObjects;
|
||||
public IPlacementObject CurrentPlacementObject { get; private set; }
|
||||
public bool TryGetCurrentObject(out IPlacementObject placementObject)
|
||||
{
|
||||
placementObject = CurrentPlacementObject;
|
||||
return placementObject != null;
|
||||
}
|
||||
public IPlacementObject[] PlacementObjects => placementObjects.Cast<IPlacementObject>().ToArray();
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user