Skip to content

Commit

Permalink
Refactor employee personality
Browse files Browse the repository at this point in the history
  • Loading branch information
mertwole committed Aug 20, 2024
1 parent 5d3bd3a commit 1a7c2ca
Show file tree
Hide file tree
Showing 20 changed files with 207 additions and 307 deletions.
16 changes: 0 additions & 16 deletions JamGame/Assets/Prefabs/Employee/Employee.prefab
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,6 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 735ac89528270c746b09f4c604991e52, type: 3}
m_Name:
m_EditorClassIdentifier:
personality: {fileID: 7027475554387804411}
employee: {fileID: 7027475554387804409}
name_text: {fileID: 8271836159909123415}
quirkViewsLabel:
Expand Down Expand Up @@ -849,7 +848,6 @@ GameObject:
- component: {fileID: 7027475554387804391}
- component: {fileID: 7027475554387804408}
- component: {fileID: 7027475554387804409}
- component: {fileID: 7027475554387804411}
- component: {fileID: 6274426418331602746}
- component: {fileID: 7027475554387804412}
- component: {fileID: 744904379}
Expand Down Expand Up @@ -1007,20 +1005,6 @@ MonoBehaviour:
incomeGenerator: {fileID: 2575964175689351513}
keepDistanceFromNextInLine: {x: 1.2, y: 1.3}
registeredModifiers: []
--- !u!114 &7027475554387804411
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 7027475554387804413}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 1c3a921a269683844adf1acfc030e74d, type: 3}
m_Name:
m_EditorClassIdentifier:
name_: John
quirks: []
--- !u!114 &6274426418331602746
MonoBehaviour:
m_ObjectHideFlags: 0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ MonoBehaviour:
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 57826b9781e118947a17eb4a12484c96, type: 3}
m_Name: EmployeeNameList
m_Script: {fileID: 11500000, guid: 17fdcae30752e9a4d92db845ff3d3ffb, type: 3}
m_Name: NameList
m_EditorClassIdentifier:
firstNames:
- Hudson
Expand Down

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 @@ -27,6 +27,13 @@ MonoBehaviour:
references:
version: 2
RefIds:
- rid: 4331002058033856516
type: {class: FixedConfig, ns: Employee.Personality, asm: Assembly-CSharp}
data:
name: John Appleseed
hireCost: 100
profession: Software Engineer
quirks: []
- rid: 8023115963875983388
type: {class: Cutscene, ns: Level.Config, asm: Assembly-CSharp}
data:
Expand Down Expand Up @@ -54,9 +61,7 @@ MonoBehaviour:
type: {class: Meeting, ns: Level.Config, asm: Assembly-CSharp}
data:
shopEmployees:
- rid: 8023115963875983399
- rid: 8023115963875983400
- rid: 8023115963875983406
- rid: 4331002058033856516
mode: 1
shopRooms:
- rid: 8023115963875983401
Expand Down Expand Up @@ -92,34 +97,6 @@ MonoBehaviour:
duration:
seconds: 1.5
text: Day Ended
- rid: 8023115963875983399
type: {class: RandomEmployeeConfig, ns: Level.Config, asm: Assembly-CSharp}
data:
nameList: {fileID: 11400000, guid: 9cfeb54453d2df345b5583d794c43760, type: 2}
costRange:
Min: 10
Max: 60
Multiply: 5
quirkList:
QuirkChance: 0.2
Quirks:
- {fileID: 11400000, guid: 1156cf1b31295974b9f193ed3f761170, type: 2}
- {fileID: 11400000, guid: f0e19fd7eb5f01940a1e652f0dbc564f, type: 2}
- {fileID: 11400000, guid: e251cd156eeb0a343a3b80129ea24798, type: 2}
- rid: 8023115963875983400
type: {class: RandomEmployeeConfig, ns: Level.Config, asm: Assembly-CSharp}
data:
nameList: {fileID: 11400000, guid: 9cfeb54453d2df345b5583d794c43760, type: 2}
costRange:
Min: 10
Max: 60
Multiply: 5
quirkList:
QuirkChance: 0.2
Quirks:
- {fileID: 11400000, guid: 1156cf1b31295974b9f193ed3f761170, type: 2}
- {fileID: 11400000, guid: f0e19fd7eb5f01940a1e652f0dbc564f, type: 2}
- {fileID: 11400000, guid: e251cd156eeb0a343a3b80129ea24798, type: 2}
- rid: 8023115963875983401
type: {class: FixedRoomConfig, ns: Level.Config, asm: Assembly-CSharp}
data:
Expand All @@ -128,17 +105,3 @@ MonoBehaviour:
type: {class: FixedRoomConfig, ns: Level.Config, asm: Assembly-CSharp}
data:
room: {fileID: 739786844684371711, guid: 12f9d01fff44d1f469de9bec77ff7e01, type: 3}
- rid: 8023115963875983406
type: {class: RandomEmployeeConfig, ns: Level.Config, asm: Assembly-CSharp}
data:
nameList: {fileID: 11400000, guid: 9cfeb54453d2df345b5583d794c43760, type: 2}
costRange:
Min: 10
Max: 60
Multiply: 5
quirkList:
QuirkChance: 0.2
Quirks:
- {fileID: 11400000, guid: 1156cf1b31295974b9f193ed3f761170, type: 2}
- {fileID: 11400000, guid: f0e19fd7eb5f01940a1e652f0dbc564f, type: 2}
- {fileID: 11400000, guid: e251cd156eeb0a343a3b80129ea24798, type: 2}
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,7 @@ MonoBehaviour:
type: {class: Meeting, ns: Level.Config, asm: Assembly-CSharp}
data:
shopEmployees:
- rid: 8023115963875983386
- rid: 8023115963875983387
- rid: 8023115963875983405
- rid: 4331002058033856515
mode: 1
shopRooms:
- rid: 1908735064151687180
Expand Down Expand Up @@ -117,28 +115,14 @@ MonoBehaviour:
type: {class: FixedRoomConfig, ns: Level.Config, asm: Assembly-CSharp}
data:
room: {fileID: 739786844684371711, guid: 12f9d01fff44d1f469de9bec77ff7e01, type: 3}
- rid: 8023115963875983386
type: {class: RandomEmployeeConfig, ns: Level.Config, asm: Assembly-CSharp}
- rid: 4331002058033856515
type: {class: RandomConfig, ns: Employee.Personality.Config, asm: Assembly-CSharp}
data:
nameList: {fileID: 11400000, guid: 9cfeb54453d2df345b5583d794c43760, type: 2}
nameList: {fileID: 11400000, guid: d3768e6f3adf815449b7c57a30e90b99, type: 2}
costRange:
Min: 10
Max: 60
Multiply: 5
quirkList:
QuirkChance: 0.2
Quirks:
- {fileID: 11400000, guid: 1156cf1b31295974b9f193ed3f761170, type: 2}
- {fileID: 11400000, guid: f0e19fd7eb5f01940a1e652f0dbc564f, type: 2}
- {fileID: 11400000, guid: e251cd156eeb0a343a3b80129ea24798, type: 2}
- rid: 8023115963875983387
type: {class: RandomEmployeeConfig, ns: Level.Config, asm: Assembly-CSharp}
data:
nameList: {fileID: 11400000, guid: 9cfeb54453d2df345b5583d794c43760, type: 2}
costRange:
Min: 10
Max: 60
Multiply: 5
Min: 5
Max: 30
Multiply: 10
quirkList:
QuirkChance: 0.2
Quirks:
Expand All @@ -151,17 +135,3 @@ MonoBehaviour:
configMode: 1
dayActions: []
preset: {fileID: 11400000, guid: b6e7115d9042bb04398c4f272c0e0ac5, type: 2}
- rid: 8023115963875983405
type: {class: RandomEmployeeConfig, ns: Level.Config, asm: Assembly-CSharp}
data:
nameList: {fileID: 11400000, guid: 9cfeb54453d2df345b5583d794c43760, type: 2}
costRange:
Min: 10
Max: 60
Multiply: 5
quirkList:
QuirkChance: 0.2
Quirks:
- {fileID: 11400000, guid: 1156cf1b31295974b9f193ed3f761170, type: 2}
- {fileID: 11400000, guid: f0e19fd7eb5f01940a1e652f0dbc564f, type: 2}
- {fileID: 11400000, guid: e251cd156eeb0a343a3b80129ea24798, type: 2}
41 changes: 38 additions & 3 deletions JamGame/Assets/Scripts/Employee/EmployeeImpl.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Common;
using Employee.Controller;
using Employee.Needs;
using Employee.Personality;
using Employee.StressMeter;
using Level.Config;
using Level.Boss.Task;
using Level.GlobalTime;
using Location;
using Sirenix.OdinInspector;
Expand Down Expand Up @@ -62,6 +64,13 @@ public NeedProviderManager NeedProviderManager
[SerializeField]
private Vector2 keepDistanceFromNextInLine = new(1.0f, 1.5f);

[SerializeField]
[ReadOnly]
private PersonalityImpl personality;
public PersonalityImpl Personality => personality;

private DataProvider<EmployeeQuirks> employeeQuirksDataProvider;

private void OnEnable()
{
controller.OnReachedNeedProvider += ReachedNeedProvider;
Expand Down Expand Up @@ -335,9 +344,35 @@ public void ReleasedFromNeedProvider()
controller.SetNavigationMode(ControllerImpl.NavigationMode.Navmesh);
}

public void SetConfig(EmployeeConfig employeeConfig)
public void SetPersonality(PersonalityImpl personality)
{
// TODO: Implement config filling (#121)
if (this.personality != null)
{
Debug.LogError(
"Attempted to set personality config for already initialized employee"
);
return;
}

this.personality = personality;

foreach (Quirk quirk in personality.Quirks)
{
foreach (Need.NeedProperties additional_need in quirk.AdditionalNeeds)
{
AddNeed(additional_need);
}

foreach (IEffect effect in quirk.Effects)
{
RegisterEffect(effect);
}
}

employeeQuirksDataProvider = new DataProvider<EmployeeQuirks>(
() => new EmployeeQuirks() { Quirks = this.personality.Quirks },
DataProviderServiceLocator.ResolveType.MultipleSources
);
}
}
}
8 changes: 2 additions & 6 deletions JamGame/Assets/Scripts/Employee/ExtendedInfo/View.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,6 @@ public class View : MonoBehaviour
{
private Camera cam;

[SerializeField]
[Required]
private PersonalityImpl personality;

[SerializeField]
[Required]
private EmployeeImpl employee;
Expand Down Expand Up @@ -69,7 +65,7 @@ private void Awake()
AddBuff(buff);
}

foreach (Quirk quirk in personality.Quirks)
foreach (Quirk quirk in employee.Personality.Quirks)
{
AddQuirk(quirk);
}
Expand All @@ -95,7 +91,7 @@ private void InitModelViewMaps()
private void Update()
{
transform.LookAt(cam.transform.position);
name_text.text = $"{personality.Name}";
name_text.text = $"{employee.Personality.Name}";
}

public void OnBuffsChanged(object sender, NotifyCollectionChangedEventArgs e)
Expand Down
8 changes: 8 additions & 0 deletions JamGame/Assets/Scripts/Employee/Personality/Config.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 @@ -2,11 +2,11 @@
using System.Collections.Generic;
using UnityEngine;

namespace Level.Config
namespace Employee.Personality
{
[Serializable]
[CreateAssetMenu(fileName = "EmployeeNameList", menuName = "Level/EmployeeNameList")]
public class EmployeeNameList : ScriptableObject
[CreateAssetMenu(fileName = "NameList", menuName = "Employee/NameList")]
public class NameList : ScriptableObject
{
[SerializeField]
private List<string> firstNames = new();
Expand Down

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

Loading

0 comments on commit 1a7c2ca

Please sign in to comment.