Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Virtual objects support #499

Merged
merged 3 commits into from
Jun 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Assets/Scripts/Enums_Strucs/FixedValues.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ public class Category
public const string Corridor = "corridor";
public const string Sensor = "sensor";
public const string Generic = "generic";
public const string VirtualObject = "virtual_obj";
}

public class CommandType
Expand Down
2 changes: 1 addition & 1 deletion Assets/Scripts/Network/ApiManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,7 @@ public async Task PostTemplateObject(string _json, string _type)
return;
}
// Debug.Log(_json);
string fullPath = $"{server}/{_type}-templates";
string fullPath = $"{server}/{_type}_templates";

StringContent content = new(_json, System.Text.Encoding.UTF8, "application/json");
try
Expand Down
9 changes: 6 additions & 3 deletions Assets/Scripts/OgreeGenerators/OgreeGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,21 +48,21 @@ public async Task<OgreeObject> CreateItemFromSApiObject(SApiObject _obj, Transfo
&& !GameManager.instance.buildingTemplates.ContainsKey((string)_obj.attributes["template"]))
{
Debug.Log($"Get template \"{_obj.attributes["template"]}\" from API");
await ApiManager.instance.GetObject($"bldg-templates/{_obj.attributes["template"]}", ApiManager.instance.CreateTemplateFromJson);
await ApiManager.instance.GetObject($"bldg_templates/{_obj.attributes["template"]}", ApiManager.instance.CreateTemplateFromJson);
}

if (_obj.category == Category.Room && _obj.attributes.HasKeyAndValue("template")
&& !GameManager.instance.roomTemplates.ContainsKey((string)_obj.attributes["template"]))
{
Debug.Log($"Get template \"{_obj.attributes["template"]}\" from API");
await ApiManager.instance.GetObject($"room-templates/{_obj.attributes["template"]}", ApiManager.instance.CreateTemplateFromJson);
await ApiManager.instance.GetObject($"room_templates/{_obj.attributes["template"]}", ApiManager.instance.CreateTemplateFromJson);
}

if ((_obj.category == Category.Rack || _obj.category == Category.Device || _obj.category == Category.Generic) && _obj.attributes.HasKeyAndValue("template")
&& !GameManager.instance.objectTemplates.ContainsKey((string)_obj.attributes["template"]))
{
Debug.Log($"Get template \"{_obj.attributes["template"]}\" from API");
await ApiManager.instance.GetObject($"obj-templates/{_obj.attributes["template"]}", ApiManager.instance.CreateTemplateFromJson);
await ApiManager.instance.GetObject($"obj_templates/{_obj.attributes["template"]}", ApiManager.instance.CreateTemplateFromJson);
}

// Tags
Expand Down Expand Up @@ -146,6 +146,9 @@ public async Task<OgreeObject> CreateItemFromSApiObject(SApiObject _obj, Transfo
case Category.Generic:
newObject = objectGenerator.CreateGeneric(_obj, parent);
break;
case Category.VirtualObject:
newObject = null;
break;
default:
newObject = null;
GameManager.instance.AppendLogLine(new ExtendedLocalizedString("Logs", "Unknown object category", _obj.category), ELogTarget.both, ELogtype.error);
Expand Down