Skip to content

Commit

Permalink
Refactored file system. Added Actor.
Browse files Browse the repository at this point in the history
  • Loading branch information
toastisme committed Apr 2, 2022
1 parent 6d59a51 commit 65d0d5c
Show file tree
Hide file tree
Showing 67 changed files with 508 additions and 33 deletions.
54 changes: 54 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Unity Editor",
"type": "unity",
"path": "/d:/UnityProjects/OpenGOAP/Library/EditorInstance.json",
"request": "launch"
},
{
"name": "Windows Player",
"type": "unity",
"request": "launch"
},
{
"name": "OSX Player",
"type": "unity",
"request": "launch"
},
{
"name": "Linux Player",
"type": "unity",
"request": "launch"
},
{
"name": "iOS Player",
"type": "unity",
"request": "launch"
},
{
"name": "Android Player",
"type": "unity",
"request": "launch"
},
{
"name": "Xbox One Player",
"type": "unity",
"request": "launch"
},
{
"name": "PS4 Player",
"type": "unity",
"request": "launch"
},
{
"name": "SwitchPlayer",
"type": "unity",
"request": "launch"
}
]
}
31 changes: 31 additions & 0 deletions Assets/Runtime/Actor.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Actor : Detectable
{
/**
* Class that can use SmartObjects
*/

protected List<SmartObject> inventory;

protected override void Start(){
base.Start();
inventory = new List<SmartObject>();
}

public virtual void PickUp(SmartObject obj){
inventory.Add(obj);
obj.PickedUp();
}
public virtual void PutDown(SmartObject obj){
inventory.Remove(obj);
obj.PutDown();
}
public virtual void AddTo(SmartObject obj, SmartObject objToAdd){
inventory.Remove(objToAdd);
obj.Add(objToAdd);
}

}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 1 addition & 6 deletions Assets/Runtime/Detectable.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
using System.Collections.Generic;
using UnityEngine;

namespace Sensors{
public class Detectable : MonoBehaviour
{
public string typeName {get; protected set;}
protected virtual void Start()
{
DetectableManager.Instance?.Add(this);
Expand All @@ -13,9 +13,4 @@ protected virtual void Start()
void OnDestroy(){
DetectableManager.Instance?.Remove(this);
}

public virtual string Name(){
return "Detectable";
}
}
}
11 changes: 11 additions & 0 deletions Assets/Runtime/Detectable.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions Assets/Runtime/GOAP.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
18 changes: 0 additions & 18 deletions Assets/Runtime/Goals.cs

This file was deleted.

9 changes: 9 additions & 0 deletions Assets/Runtime/IActor.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
using UnityEngine;

public interface IActor
{
void PickUp(SmartObject obj);
void PutDown(SmartObject obj);
void AddTo(SmartObject obj, SmartObject objToAdd);

}
11 changes: 11 additions & 0 deletions Assets/Runtime/IActor.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions Assets/Runtime/Managers/DetectableManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
using UnityEngine;
using UnityEngine.Assertions;

namespace Sensors{
public class DetectableManager : MonoBehaviour
{
public static DetectableManager Instance {get; private set;} = null;
Expand All @@ -21,5 +20,4 @@ public void Add(Detectable detectable){
public void Remove(Detectable detectable){
Detectables.Remove(detectable);
}
}
}
8 changes: 8 additions & 0 deletions Assets/Runtime/Materials.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

79 changes: 79 additions & 0 deletions Assets/Runtime/Materials/Terrain.mat
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!21 &2100000
Material:
serializedVersion: 6
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: Terrain
m_Shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0}
m_ShaderKeywords:
m_LightmapFlags: 4
m_EnableInstancingVariants: 0
m_DoubleSidedGI: 0
m_CustomRenderQueue: -1
stringTagMap: {}
disabledShaderPasses: []
m_SavedProperties:
serializedVersion: 3
m_TexEnvs:
- _BumpMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailAlbedoMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailMask:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailNormalMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _EmissionMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MainTex:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MetallicGlossMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _OcclusionMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _ParallaxMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
m_Ints: []
m_Floats:
- _BumpScale: 1
- _Cutoff: 0.5
- _DetailNormalMapScale: 1
- _DstBlend: 0
- _GlossMapScale: 1
- _Glossiness: 0.5
- _GlossyReflections: 1
- _Metallic: 0
- _Mode: 0
- _OcclusionStrength: 1
- _Parallax: 0.02
- _SmoothnessTextureChannel: 0
- _SpecularHighlights: 1
- _SrcBlend: 1
- _UVSec: 0
- _ZWrite: 1
m_Colors:
- _Color: {r: 0, g: 0, b: 0, a: 1}
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
m_BuildTextureStacks: []
8 changes: 8 additions & 0 deletions Assets/Runtime/Materials/Terrain.mat.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion Assets/Runtime/Movement.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.AI;
using Sensors;

[RequireComponent(typeof(NavMeshAgent))]
public class Movement : MonoBehaviour
Expand Down
8 changes: 8 additions & 0 deletions Assets/Runtime/Sensors.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public Detectable GetNearest(string name){
Detectable nearest;
float minDistance = -1f;
foreach(var obj in nearbyObjects){
if (obj.Key.name == name){
if (obj.Key.typeName == name){
float distance = (obj.Key.transform.position - transform.position).sqrMagnitude;
if (minDistance < 0 || distance < minDistance){
nearest = obj.Key;
Expand Down Expand Up @@ -98,16 +98,16 @@ void UpdateWorldState(){

void Forget(Detectable obj){
nearbyObjects.Remove(obj);
nearbyObjectCounts[obj.Name()] -= 1;
nearbyObjectCounts[obj.typeName] -= 1;
}

public void Add(Detectable obj, float memory, float memoryDecay){
nearbyObjects[obj] = new NearbyObject(obj, memory, memoryDecay);
if (nearbyObjectCounts.ContainsKey(obj.Name())){
nearbyObjectCounts[obj.Name()] += 1;
if (nearbyObjectCounts.ContainsKey(obj.typeName)){
nearbyObjectCounts[obj.typeName] += 1;
}
else{
nearbyObjectCounts[obj.Name()] = 1;
nearbyObjectCounts[obj.typeName] = 1;
}
}
}
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
8 changes: 8 additions & 0 deletions Assets/Runtime/SmartObjects.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions Assets/Runtime/SmartObjects/ISmartObject.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
using UnityEngine;

public interface ISmartObject
{
void PickedUp(){}
void PutDown(){}
void Add(SmartObject obj){}
void Remove(){}

}
11 changes: 11 additions & 0 deletions Assets/Runtime/SmartObjects/ISmartObject.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 28 additions & 0 deletions Assets/Runtime/SmartObjects/SmartObject.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class SmartObject : Detectable, ISmartObject
{
Renderer rend;
protected override void Start()
{
base.Start();
rend = GetComponent<Renderer>();
}

public virtual void PickedUp(){
rend.enabled = false;
}

public virtual void PutDown(){
rend.enabled = true;
}

public virtual void Add(SmartObject obj){}

public virtual void Remove(){
Destroy(this);
}

}
Loading

0 comments on commit 65d0d5c

Please sign in to comment.