Shrunk the peep struct size and made all structs readonly, + updated Unity version.

This commit is contained in:
Bas
2020-10-24 21:33:21 +02:00
parent 28d50b765c
commit 91ee32f52b
28 changed files with 500 additions and 354 deletions

View File

@@ -19,7 +19,7 @@ As of now there are no release builds yet, because the project is still very muc
To get it running inside of Unity, you need the following prerequisites:
- Everything mentioned in OpenRCT2's original [building prerequisites](#31-building-prerequisites).
- [Unity Editor version LTS 2019.4.6f1](https://unity3d.com/unity/qa/lts-releases?version=2019.4).
- [Unity Editor version LTS 2019.4.13f1](https://unity3d.com/unity/qa/lts-releases?version=2019.4).
**Note:** only the Windows setup has been tested.

View File

@@ -14,8 +14,21 @@ extern "C"
}
struct PeepEntity
{
public:
uint16_t idx;
int32_t x;
int32_t y;
int32_t z;
uint8_t tshirt_colour;
uint8_t trousers_colour;
};
// Loads all the peeps into the specified buffer, returns the total amount of peeps loaded.
EXPORT int GetAllPeeps(Peep* peeps, int arraySize)
EXPORT int GetAllPeeps(PeepEntity* peeps, int arraySize)
{
Peep* peep;
uint16_t spriteIndex;
@@ -23,7 +36,14 @@ extern "C"
FOR_ALL_PEEPS (spriteIndex, peep)
{
peeps[peepCount] = *peep;
PeepEntity* data = &peeps[peepCount];
data->idx = peep->sprite_index;
data->x = peep->x;
data->y = peep->y;
data->z = peep->z;
data->tshirt_colour = peep->tshirt_colour;
data->trousers_colour = peep->trousers_colour;
peepCount++;
if (peepCount >= arraySize)
@@ -33,7 +53,41 @@ extern "C"
}
struct RideVehicle
struct PeepStats
{
public:
uint8_t energy;
uint8_t happiness;
uint8_t nausea;
uint8_t hunger;
uint8_t thirst;
uint8_t toilet;
uint8_t intensity;
};
EXPORT bool GetPeepStats(uint16_t spriteIndex, PeepStats* peepStats)
{
Peep* peep = GET_PEEP(spriteIndex);
if (peep != nullptr)
{
printf("(me) Peep does not exist anymore. ( sprite id: %i )\n", spriteIndex);
return false;
}
peepStats->energy = peep->energy;
peepStats->happiness = peep->happiness;
peepStats->nausea = peep->nausea;
peepStats->hunger = peep->hunger;
peepStats->thirst = peep->thirst;
peepStats->toilet = peep->toilet;
peepStats->intensity = peep->intensity;
return true;
}
struct VehicleEntity
{
public:
uint16_t idx;
@@ -50,7 +104,7 @@ extern "C"
// Loads all the vehicles into the specified buffer, returns the total amount of vehicles loaded.
EXPORT int GetAllVehicles(RideVehicle* vehicles, int arraySize)
EXPORT int GetAllVehicles(VehicleEntity* vehicles, int arraySize)
{
Vehicle *train, *vehicle;
int vehicleCount = 0;
@@ -67,7 +121,7 @@ extern "C"
//printf("(me) %i vehicle %i at %i, %i, %i\n", vehicleCount, vehicle->sprite_index, vehicle->x, vehicle->y, vehicle->z);
RideVehicle* target = &vehicles[vehicleCount];
VehicleEntity* target = &vehicles[vehicleCount];
target->idx = vehicle->sprite_index;
target->x = vehicle->x;

View File

@@ -4,7 +4,6 @@
static const float2 aspect_ratio = float2(64, 31); // max pixel width+height of a tile.
static const float scale = 1 / 1.41421356237; // diagonal tile distance.
static const float radians = 0.785398163; // 45 degrees in radians.
static const float3x3 rotation_matrix = float3x3 // this is correct now for rotating in 3d
@@ -266,4 +265,98 @@ void Rct_path_matrix_float(float2 uv, float2 size, float2 offset, out float2 Out
return;
}
float3x3 matrix_euler_rot(float3 rotation)
{
float x = radians(rotation.x);
float3x3 mat_x = float3x3
(
1, 0, 0,
0, cos(x), -sin(x),
0, sin(x), cos(x)
);
float y = radians(rotation.y);
float3x3 mat_y = float3x3
(
cos(y), 0, sin(y),
0, 1, 0,
-sin(y), 0, cos(y)
);
float z = radians(rotation.z);
float3x3 mat_z = float3x3
(
cos(z), -sin(z), 0,
sin(z), cos(z), 0,
0, 0, 1
);
return (mat_z * mat_y * mat_x);
}
float3x3 rotationMatrix(float3 axis, float angle)
{
// the usual method, copied from
// http://www.neilmendoza.com/glsl-rotation-about-an-arbitrary-axis/
//
axis = normalize(axis);
float s = sin(angle);
float c = cos(angle);
float oc = 1.0 - c;
return float3x3
(
oc * axis.x * axis.x + c, oc * axis.x * axis.y - axis.z * s, oc * axis.z * axis.x + axis.y * s,
oc * axis.x * axis.y + axis.z * s, oc * axis.y * axis.y + c, oc * axis.y * axis.z - axis.x * s,
oc * axis.z * axis.x - axis.y * s, oc * axis.y * axis.z + axis.x * s, oc * axis.z * axis.z + c
);
}
float3x3 createCameraYPR(float cameraYaw, float cameraPitch, float cameraRoll)
{
float3 forward = -normalize(float3(sin(cameraYaw), sin(cameraPitch), cos(cameraYaw)));
float3 up = float3(0.0, 1.0, 0.0);
float3 cameraRight = normalize(cross(forward, up));
float3 cameraUp = normalize(cross(cameraRight, forward));
return rotationMatrix(forward, cameraRoll) * float3x3(cameraRight, cameraUp, forward);
}
float remap(float value, float2 from, float2 to)
{
return ((value - from.x) / (from.y - from.x)) * (to.y - to.x) + to.x;
}
float2 resize_rct(float2 uv, float2 size, float2 offset)
{
float2 scaled = uv * size;
return float2
(
remap(scaled.x, float2(0, size.x), float2(-offset.x - 32, -offset.x + 32)),
remap(scaled.y, float2(0, size.y), float2((size.y + offset.y) - 31, size.y + offset.y))
);
}
void resize_rct_float(float2 uv, float2 size, float2 offset, out float2 Out)
{
Out = resize_rct(uv, size, offset);
}
void matrix_euler_rot_float(float2 uv, float3 rotation, out float3 Out)
{
float3x3 cameraMatrix = createCameraYPR(radians(rotation.x), radians(rotation.y), radians(rotation.z));
Out = mul(cameraMatrix, normalize(float3(uv, 1)));
//float3x3 mat = matrix_euler_rot(rotation);
//Out = mul(mat, float3(uv, 1));
}
#endif

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: a04551dc34cd72f47887b21de48fe40a
ScriptedImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 2
userData:
assetBundleName:
assetBundleVariant:
script: {fileID: 11500000, guid: 625f186215c104763be7675aa2d941aa, type: 3}

View File

@@ -168,7 +168,7 @@ GameObject:
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_StaticEditorFlags: 4294967295
m_IsActive: 1
--- !u!114 &108384298
MonoBehaviour:
@@ -465,7 +465,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 49e4dcf5847a0b1499de244f93c83a43, type: 3}
m_Name:
m_EditorClassIdentifier:
canvasManager: {fileID: 1779574330}
windowManager: {fileID: 1779574330}
peepController: {fileID: 1491562773}
--- !u!1 &457888653
GameObject:
@@ -1057,7 +1057,7 @@ GameObject:
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 4294967295
m_IsActive: 0
m_IsActive: 1
--- !u!114 &885425400
MonoBehaviour:
m_ObjectHideFlags: 0
@@ -1496,7 +1496,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 79be679884da2154dacd80be9669d5dc, type: 3}
m_Name:
m_EditorClassIdentifier:
selectedPark: Three Monkeys Park.sv6
selectedPark: Europe - European Cultural Festival.SC6
--- !u!4 &1347800243
Transform:
m_ObjectHideFlags: 0
@@ -2141,7 +2141,7 @@ GameObject:
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_StaticEditorFlags: 4294967295
m_IsActive: 1
--- !u!114 &1779574330
MonoBehaviour:
@@ -2155,9 +2155,9 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: eb1ffec044d775144bb9308228979414, type: 3}
m_Name:
m_EditorClassIdentifier:
peepBox: {fileID: 8219538139994365458, guid: 8f7aedb4e26ded34b9d6c0a26bff6792, type: 3}
peepCanvas: {fileID: 885425399}
peepController: {fileID: 1491562773}
peepWindowPrefab: {fileID: 8219538139994365458, guid: 8f7aedb4e26ded34b9d6c0a26bff6792,
type: 3}
parentCanvas: {fileID: 885425399}
--- !u!224 &1779574331
RectTransform:
m_ObjectHideFlags: 0

View File

@@ -16,10 +16,6 @@ namespace Lib
static extern int GetAllPeeps([Out] Peep[] elements, int arraySize);
[DllImport(PluginFile, CallingConvention = CallingConvention.Cdecl)]
static extern int GetAllVehicles([Out] Vehicle[] elements, int arraySize);
/// <summary>
/// Returns all peeps in the park.
/// </summary>
@@ -42,6 +38,19 @@ namespace Lib
=> GetAllPeeps(buffer, buffer.Length);
/// <summary>
/// Gets certain statiscics about this peep, like its hunger or energy.
/// Returns true if the peep stats were succesfully read, or false if
/// the peep does not exist (anymore).
/// </summary>
[DllImport(PluginFile, CallingConvention = CallingConvention.Cdecl)]
internal static extern bool GetPeepStats(ushort spriteIndex, ref PeepStats peepStats);
[DllImport(PluginFile, CallingConvention = CallingConvention.Cdecl)]
static extern int GetAllVehicles([Out] Vehicle[] elements, int arraySize);
/// <summary>
/// Reads all vehicles in the park into the specified buffer.
/// </summary>

View File

@@ -4,12 +4,12 @@ using UnityEngine;
namespace Lib
{
[StructLayout(LayoutKind.Sequential, Size = 4)]
public struct PaletteEntry
public readonly struct PaletteEntry
{
public byte blue;
public byte green;
public byte red;
public byte alpha;
public readonly byte blue;
public readonly byte green;
public readonly byte red;
public readonly byte alpha;
// Converts the 0-255 color byte to a float between 0 and 1.

View File

@@ -1,4 +1,3 @@
using System;
using System.Runtime.InteropServices;
using Sprites;
using UnityEngine;
@@ -8,97 +7,29 @@ namespace Lib
/// <summary>
/// The struct of a peep, which can be either a guest or a staff member.
/// </summary>
[StructLayout(LayoutKind.Sequential, Size = (256 + Ptr.Size))]
public struct Peep : ISprite
[StructLayout(LayoutKind.Sequential)]
public readonly struct Peep : ISprite
{
public SpriteBase sprite;
public IntPtr namePtr; // The real name
public int nextLocX;
public int nextLocY;
public int nextLocZ;
public byte nextFlags;
public byte outsideOfPark;
public PeepState state;
public PeepSubState substate;
public PeepSpriteType spriteType;
public PeepType type;
public byte staffTypeOrNoOfRides; // union of staff type or no. of rides.
public byte tshirtColour;
public byte trousersColour;
public ushort destinationX; // Location that the peep is trying to get to
public ushort destinationY;
public byte destinationTolerance; // How close to destination before next action/state 0 = exact
public byte var37;
public byte energy;
public byte energyTarget;
public byte happiness;
public byte happinessTarget;
public byte nausea;
public byte nauseaTarget;
public byte hunger;
public byte thirst;
public byte toilet;
public byte mass;
public byte timeToConsume;
public byte intensity; // The max intensity is stored in the first 4 bits, and the min intensity in the second 4 bits
public byte nauseaTolerance;
public byte windowInvalidateFlags;
public short paidOnDrink;
public long rideTypesBeenOn1; // This is 16x a byte for a ride;
public long rideTypesBeenOn2;
public uint itemExtraFlags;
public byte photo2RideRef;
public byte photo3RideRef;
public byte photo4RideRef;
public byte currentRide;
public byte stationIndex;
public byte currentTrain;
public ushort currentCarAndSeatOrTimeToSitDownOrTimeToStandAndStandingFlags;
public byte specialSprite;
public PeepActionSprite actionSpriteType;
public PeepActionSprite nextActionSpriteType;
public byte actionSpriteImageOffset;
public PeepAction action;
public byte actionFrame;
public byte stepProgress;
public ushort MechanicTimeSinceCallOrNextInQueue; // time getting to ride to fix
public byte MazeLastEdgeOrDirection;
public byte interactionRideIndex;
public ushort timeInQueue;
public long ridesBeenOn1;
public long ridesBeenOn2;
public long ridesBeenOn3;
public long ridesBeenOn4;
public uint id;
public int cashInPocket;
public int cashSpent;
public int timeInPark;
public byte rejoinQueueTimeOut;
public byte previousRide;
public ushort previousRideTimeOut;
public uint peepThoughts;
public byte pathCheckOptimisation;
public byte staffIdOrGuestHeadingToRideId;
public byte staffOrdersOrPeepIsLostCountdown;
public byte photo1RideRef;
public uint peepFlags;
public readonly ushort idx;
public readonly int x;
public readonly int y;
public readonly int z;
public readonly byte tshirtColour;
public readonly byte trousersColour;
/// <summary>
/// Returns an id of the peep, currently based on the sprite index.
/// </summary>
public ushort Id
=> sprite.spriteIndex;
public string Name
=> Marshal.PtrToStringAuto(namePtr);
=> idx;
/// <summary>
/// Returns the peep's position in Unity coordinates.
/// </summary>
public Vector3 Position
=> Map.CoordsToVector3(sprite.x, sprite.z, sprite.y);
=> Map.CoordsToVector3(x, z, y);
}
}

View File

@@ -0,0 +1,32 @@
using System.Runtime.InteropServices;
namespace Lib
{
/// <summary>
/// This struct contains certain statistics about a peep, like its energy
/// and happiness.
/// </summary>
[StructLayout(LayoutKind.Sequential)]
public readonly struct PeepStats
{
public readonly byte energy;
public readonly byte happiness;
public readonly byte nausea;
public readonly byte hunger;
public readonly byte thirst;
public readonly byte toilet;
public readonly byte intensity; // First 4 bits = max intensity, second 4 bits = min intensity.
/// <summary>
/// Minimum intensity level for this peep.
/// </summary>
public byte MinIntensity => (byte)(intensity & 0b1111);
/// <summary>
/// Maximum intensity level for this peep.
/// </summary>
public byte MaxIntensity => (byte)(intensity >> 4);
}
}

View File

@@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: a1c934bf1aaf15445b2f43583a0b36d0
guid: 522d7dcda4f5c2e469e4d0a88107ec39
MonoImporter:
externalObjects: {}
serializedVersion: 2

View File

@@ -1,30 +0,0 @@
using System.Runtime.InteropServices;
namespace Lib
{
[StructLayout(LayoutKind.Sequential, Size = 31)]
public struct SpriteBase
{
public byte spriteIdentifier; // 0
public byte type; // 1
public ushort nextInQuadrant; // 2,3
public ushort next; // 4,5
public ushort previous; // 6,7
public byte linkedListIndex; // 8; Valid values are SPRITE_LINKEDLIST_OFFSET_...
public byte spriteHeightNegative; // 9; Height from centre of sprite to bottom
public ushort spriteIndex; // 10,11
public ushort flags; // 12,13
public short x; // 14,15
public short y; // 16,17
public short z; // 18,19
public byte spriteWidth; // 20; Width from centre of sprite to edge
public byte spriteHeightPositive; // 21; Height from centre of sprite to top
// Screen Coordinates of sprite
public short sprite_left; // 22,23
public short sprite_top; // 24,25
public short sprite_right; // 26,27
public short sprite_bottom; // 28,29
public byte sprite_direction; // 30
}
}

View File

@@ -6,16 +6,16 @@ namespace Lib
/// Struct with data on the sprite.
/// </summary>
[StructLayout(LayoutKind.Sequential, Size = 8)]
public struct SpriteData
public readonly struct SpriteData
{
// Width + height of the sprite.
public short width;
public short height;
public readonly short width;
public readonly short height;
// The x and y offset that is used to draw the sprite in
// the correct position.
public short offsetX;
public short offsetY;
public readonly short offsetX;
public readonly short offsetY;
/// <summary>

View File

@@ -10,19 +10,19 @@ namespace Lib
/// The struct of a ride vehicle.
/// </summary>
[StructLayout(LayoutKind.Sequential)]
public struct Vehicle : ISprite
public readonly struct Vehicle : ISprite
{
public ushort idx;
public int x;
public int y;
public int z;
public byte direction; // 0-31 to indicate direction, 0 = negative x axis direction
public byte bankRotation;
public byte vehicleSprite; // this is a index describing what sprite should be used; maybe useless for pitch?
public readonly ushort idx;
public readonly int x;
public readonly int y;
public readonly int z;
public readonly byte direction; // 0-31 to indicate direction, 0 = negative x axis direction
public readonly byte bankRotation;
public readonly byte vehicleSprite; // this is a index describing what sprite should be used; maybe useless for pitch?
public byte trackType; // current track type its on.
public byte trackDirection; // the direction this track type is in.
public ushort trackProgress; // current track node index.
public readonly byte trackType; // current track type its on.
public readonly byte trackDirection; // the direction this track type is in.
public readonly ushort trackProgress; // current track node index.
/// <summary>

View File

@@ -2,11 +2,11 @@ using System.Runtime.InteropServices;
namespace Lib
{
[StructLayout(LayoutKind.Sequential, Size = 3)]
public struct TrackColour
[StructLayout(LayoutKind.Sequential)]
public readonly struct TrackColour
{
public byte main;
public byte additional;
public byte supports;
public readonly byte main;
public readonly byte additional;
public readonly byte supports;
}
}

View File

@@ -5,14 +5,14 @@ using UnityEngine;
namespace Lib
{
[StructLayout(LayoutKind.Sequential)]
public struct TrackNode
public readonly struct TrackNode
{
public short x;
public short y;
public short z;
public byte direction; // 0-31 to indicate direction, 0 = negative x axis direction
public byte vehicleSprite;
public byte bankRotation;
public readonly short x;
public readonly short y;
public readonly short z;
public readonly byte direction; // 0-31 to indicate direction, 0 = negative x axis direction
public readonly byte vehicleSprite;
public readonly byte bankRotation;
// Offset to offset the node relative to the center of the start of the track, instead of the corner.

View File

@@ -7,12 +7,12 @@ namespace Lib
/// It's explicit because it seems C# likes to swap members around for performance?
/// </summary>
[StructLayout(LayoutKind.Explicit, Size = (26 + Ptr.Size))]
public struct SmallSceneryEntry
public readonly struct SmallSceneryEntry
{
/// <summary>
/// The flags of this small scenery entry.
/// </summary>
[FieldOffset(0x06)] public SmallSceneryFlags Flags;
[FieldOffset(0x06)] public readonly SmallSceneryFlags Flags;
/* Memory map:

View File

@@ -4,27 +4,27 @@ using System.Runtime.InteropServices;
namespace Lib
{
[StructLayout(LayoutKind.Sequential, Size = 16)]
public struct TileElement : IEquatable<TileElement>
public readonly struct TileElement : IEquatable<TileElement>
{
public byte type;
public byte flags;
public byte baseHeight;
public byte clearanceHeight;
public readonly byte type;
public readonly byte flags;
public readonly byte baseHeight;
public readonly byte clearanceHeight;
public byte slot0x1;
public byte slot0x2;
public byte slot0x3;
public byte slot0x4;
public readonly byte slot0x1;
public readonly byte slot0x2;
public readonly byte slot0x3;
public readonly byte slot0x4;
public byte slot0x5;
public byte slot0x6;
public byte slot0x7;
public byte slot0x8;
public readonly byte slot0x5;
public readonly byte slot0x6;
public readonly byte slot0x7;
public readonly byte slot0x8;
public byte slot0x9;
public byte slot0xA;
public byte slot0xB;
public byte slot0xC;
public readonly byte slot0x9;
public readonly byte slot0xA;
public readonly byte slot0xB;
public readonly byte slot0xC;
// The mask skim off the extra bits, to retrieve the actual type.
@@ -54,7 +54,7 @@ namespace Lib
/// <summary>
/// Compares two tile elements to see whether they are equal.
/// </summary>
public static bool Equals(ref TileElement left, ref TileElement right)
public static bool Equals(in TileElement left, in TileElement right)
=> (left.type == right.type)
&& (left.flags == right.flags)
&& (left.baseHeight == right.baseHeight)
@@ -75,22 +75,22 @@ namespace Lib
/// <inheritdoc/>
public override bool Equals(object obj)
=> (obj is TileElement tile && Equals(ref this, ref tile));
=> (obj is TileElement tile && Equals(this, tile));
/// <inheritdoc/>
public bool Equals(TileElement other)
=> (Equals(ref this, ref other));
=> (Equals(this, other));
/// <inheritdoc/>
public static bool operator ==(TileElement left, TileElement right)
=> (Equals(ref left, ref right));
=> (Equals(left, right));
/// <inheritdoc/>
public static bool operator !=(TileElement left, TileElement right)
=> (!Equals(ref left, ref right));
=> (!Equals(left, right));
/// <summary>

View File

@@ -1,4 +1,6 @@
using System.Collections.Generic;
using System.Linq;
using Graphics;
using Lib;
using UnityEngine;
@@ -11,12 +13,11 @@ namespace Sprites
{
/// <summary>
/// Find the associated peep id for the specified gameobject, or
/// null if the gameobject is not a peep.
/// Find the associated peep id for the specified gameobject.
/// </summary>
public ushort FindPeepIdForGameObject(GameObject peepObject)
{
var entry = spriteObjects.FirstOrDefault(p => p.Value.gameObject == peepObject);
KeyValuePair<ushort, SpriteObject> entry = spriteObjects.FirstOrDefault(p => p.Value.gameObject == peepObject);
int bufferIndex = entry.Value.bufferIndex;
return spriteBuffer[bufferIndex].Id;
@@ -53,8 +54,9 @@ namespace Sprites
GameObject obj = spriteObject.gameObject;
ushort id = sprite.Id;
PeepType type = sprite.type;
obj.name = $"{type} {id}";
obj.name = $"Peep sprite {id}";
//PeepType type = sprite.type;
//obj.name = $"{type} {id}";
UpdateColours(obj, ref sprite);
return spriteObject;
@@ -93,116 +95,8 @@ namespace Sprites
var tshirtRenderer = tshirt.GetComponent<Renderer>();
var trousersRenderer = trousers.GetComponent<Renderer>();
tshirtRenderer.material.color = DecodeColour(peep.tshirtColour);
trousersRenderer.material.color = DecodeColour(peep.trousersColour);
}
Color DecodeColour(byte colour)
{
var colourRGB = new Color32(0, 0, 0, 1);
switch (colour)
{
case 0:
colourRGB = new Color32(0, 0, 0, 1);
break;
case 1:
colourRGB = new Color32(128, 128, 128, 1);
break;
case 2:
colourRGB = new Color32(255, 255, 255, 1);
break;
case 3:
colourRGB = new Color32(85, 26, 139, 1);
break;
case 4:
colourRGB = new Color32(171, 130, 255, 1);
break;
case 5:
colourRGB = new Color32(160, 32, 240, 1);
break;
case 6:
colourRGB = new Color32(0, 0, 139, 1);
break;
case 7:
colourRGB = new Color32(102, 102, 255, 1);
break;
case 8:
colourRGB = new Color32(135, 206, 235, 1);
break;
case 9:
colourRGB = new Color32(0, 128, 128, 1);
break;
case 10:
colourRGB = new Color32(127, 255, 212, 1);
break;
case 11:
colourRGB = new Color32(124, 205, 124, 1);
break;
case 12:
colourRGB = new Color32(0, 100, 0, 1);
break;
case 13:
colourRGB = new Color32(110, 139, 61, 1);
break;
case 14:
colourRGB = new Color32(0, 255, 0, 1);
break;
case 15:
colourRGB = new Color32(192, 255, 62, 1);
break;
case 16:
colourRGB = new Color32(85, 107, 47, 1);
break;
case 17:
colourRGB = new Color32(255, 255, 0, 1);
break;
case 18:
colourRGB = new Color32(139, 139, 0, 1);
break;
case 19:
colourRGB = new Color32(255, 165, 0, 1);
break;
case 20:
colourRGB = new Color32(255, 127, 0, 1);
break;
case 21:
colourRGB = new Color32(244, 164, 96, 1);
break;
case 22:
colourRGB = new Color32(165, 42, 42, 1);
break;
case 23:
colourRGB = new Color32(205, 170, 125, 1);
break;
case 24:
colourRGB = new Color32(61, 51, 37, 1);
break;
case 25:
colourRGB = new Color32(255, 160, 122, 1);
break;
case 26:
colourRGB = new Color32(205, 55, 0, 1);
break;
case 27:
colourRGB = new Color32(200, 0, 0, 1);
break;
case 28:
colourRGB = new Color32(255, 0, 0, 1);
break;
case 29:
colourRGB = new Color32(205, 16, 118, 1);
break;
case 30:
colourRGB = new Color32(255, 105, 180, 1);
break;
case 31:
colourRGB = new Color32(255, 174, 185, 1);
break;
default:
break;
}
return colourRGB;
tshirtRenderer.material.color = GraphicsFactory.PaletteToColor(peep.tshirtColour);
trousersRenderer.material.color = GraphicsFactory.PaletteToColor(peep.trousersColour);
}
}
}

View File

@@ -7,16 +7,24 @@ namespace Tools
{
public class SelectionTool : MonoBehaviour
{
[SerializeField] WindowManager canvasManager;
[SerializeField] WindowManager windowManager;
[SerializeField] PeepController peepController;
Camera mainCamera;
void Start()
{
mainCamera = Camera.main;
}
// Update is called once per frame
void Update()
{
if (Input.GetMouseButtonDown(0))
{
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
Ray ray = mainCamera.ScreenPointToRay(Input.mousePosition);
if (Physics.Raycast(ray, out RaycastHit hit))
{
@@ -31,9 +39,8 @@ namespace Tools
switch (obj.tag)
{
case "Peep":
canvasManager.CreatePeepWindow(peepController.FindPeepIdForGameObject(obj));
break;
default:
ushort peepId = peepController.FindPeepIdForGameObject(obj);
windowManager.CreatePeepWindow(peepId);
break;
}
}

Some files were not shown because too many files have changed in this diff Show More