Skip to content
This repository has been archived by the owner on Nov 27, 2024. It is now read-only.

Commit

Permalink
Added ShortDescriptions to the entity properties + fixed hassprite
Browse files Browse the repository at this point in the history
  • Loading branch information
juanjp600 committed Jun 21, 2020
1 parent d4eca60 commit a00a6b3
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 18 deletions.
28 changes: 14 additions & 14 deletions CBRE.DataStructures/GameData/GameData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,29 +20,29 @@ public GameData()
Classes = new List<GameDataObject>();

var lightDataObj = new GameDataObject("light", "Point light source.", ClassType.Point);
lightDataObj.Properties.Add(new Property("color", VariableType.Color255) { DefaultValue = "255 255 255" });
lightDataObj.Properties.Add(new Property("intensity", VariableType.Float) { DefaultValue = "1.0" });
lightDataObj.Properties.Add(new Property("range", VariableType.Float) { DefaultValue = "1.0" });
lightDataObj.Properties.Add(new Property("hassprite", VariableType.Bool) { DefaultValue = "true" });
lightDataObj.Properties.Add(new Property("color", VariableType.Color255) { ShortDescription = "Color", DefaultValue = "255 255 255" });
lightDataObj.Properties.Add(new Property("intensity", VariableType.Float) { ShortDescription = "Intensity", DefaultValue = "1.0" });
lightDataObj.Properties.Add(new Property("range", VariableType.Float) { ShortDescription = "Range", DefaultValue = "1.0" });
lightDataObj.Properties.Add(new Property("hassprite", VariableType.Bool) { ShortDescription = "Has sprite", DefaultValue = "Yes" });
lightDataObj.Behaviours.Add(new Behaviour("sprite", "sprites/lightbulb.spr"));
Classes.Add(lightDataObj);

var spotlightDataObj = new GameDataObject("spotlight", "Self-explanatory.", ClassType.Point);
spotlightDataObj.Properties.Add(new Property("color", VariableType.Color255) { DefaultValue = "255 255 255" });
spotlightDataObj.Properties.Add(new Property("intensity", VariableType.Float) { DefaultValue = "1.0" });
spotlightDataObj.Properties.Add(new Property("range", VariableType.Float) { DefaultValue = "1.0" });
spotlightDataObj.Properties.Add(new Property("hassprite", VariableType.Bool) { DefaultValue = "true" });
spotlightDataObj.Properties.Add(new Property("innerconeangle", VariableType.Float) { DefaultValue = "45" });
spotlightDataObj.Properties.Add(new Property("outerconeangle", VariableType.Float) { DefaultValue = "90" });
spotlightDataObj.Properties.Add(new Property("angles", VariableType.Vector) { DefaultValue = "0 0 0" });
spotlightDataObj.Properties.Add(new Property("color", VariableType.Color255) { ShortDescription = "Color", DefaultValue = "255 255 255" });
spotlightDataObj.Properties.Add(new Property("intensity", VariableType.Float) { ShortDescription = "Intensity", DefaultValue = "1.0" });
spotlightDataObj.Properties.Add(new Property("range", VariableType.Float) { ShortDescription = "Range", DefaultValue = "1.0" });
spotlightDataObj.Properties.Add(new Property("hassprite", VariableType.Bool) { ShortDescription = "Has sprite", DefaultValue = "Yes" });
spotlightDataObj.Properties.Add(new Property("innerconeangle", VariableType.Float) { ShortDescription = "Inner cone angle", DefaultValue = "45" });
spotlightDataObj.Properties.Add(new Property("outerconeangle", VariableType.Float) { ShortDescription = "Outer cone angle", DefaultValue = "90" });
spotlightDataObj.Properties.Add(new Property("angles", VariableType.Vector) { ShortDescription = "Rotation", DefaultValue = "0 0 0" });
Classes.Add(spotlightDataObj);
Classes.Add(new GameDataObject("waypoint", "AI waypoint.", ClassType.Point));
Classes.Add(new GameDataObject("soundemitter", "Self-explanatory.", ClassType.Point));

var modelDataObj = new GameDataObject("model", "Self-explanatory.", ClassType.Point);
modelDataObj.Properties.Add(new Property("file", VariableType.Other) { DefaultValue = "" });
modelDataObj.Properties.Add(new Property("angles", VariableType.Vector) { DefaultValue = "0 0 0" });
modelDataObj.Properties.Add(new Property("scale", VariableType.Vector) { DefaultValue = "1 1 1" });
modelDataObj.Properties.Add(new Property("file", VariableType.Other) { ShortDescription = "File", DefaultValue = "" });
modelDataObj.Properties.Add(new Property("angles", VariableType.Vector) { ShortDescription = "Rotation", DefaultValue = "0 0 0" });
modelDataObj.Properties.Add(new Property("scale", VariableType.Vector) { ShortDescription = "Scale", DefaultValue = "1 1 1" });
Classes.Add(modelDataObj);

var noShadowObj = new GameDataObject("noshadow", "Disables shadow casting for this brush.", ClassType.Solid);
Expand Down
11 changes: 7 additions & 4 deletions CBRE.Editor/Compiling/Lightmap/Light.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ class Light

public static void FindLights(Map map, out List<Light> lightEntities)
{
Predicate<string> parseBooleanProperty = (prop) =>
{
return prop.Equals("yes", StringComparison.OrdinalIgnoreCase) || prop.Equals("true", StringComparison.OrdinalIgnoreCase);
};

lightEntities = new List<Light>();
lightEntities.AddRange(map.WorldSpawn.Find(q => q.ClassName == "light").OfType<Entity>()
.Select(x =>
Expand All @@ -31,8 +36,7 @@ public static void FindLights(Map map, out List<Light> lightEntities)
float.TryParse(x.EntityData.GetPropertyValue("range"), NumberStyles.Float, CultureInfo.InvariantCulture, out range);
float intensity = 1.0f;
float.TryParse(x.EntityData.GetPropertyValue("intensity"), NumberStyles.Float, CultureInfo.InvariantCulture, out intensity);
bool hasSprite = true;
bool.TryParse(x.EntityData.GetPropertyValue("hassprite") ?? "true", out hasSprite);
bool hasSprite = parseBooleanProperty(x.EntityData.GetPropertyValue("hassprite") ?? "true");

return new Light()
{
Expand All @@ -53,8 +57,7 @@ public static void FindLights(Map map, out List<Light> lightEntities)
float.TryParse(x.EntityData.GetPropertyValue("range"), NumberStyles.Float, CultureInfo.InvariantCulture, out range);
float intensity = 1.0f;
float.TryParse(x.EntityData.GetPropertyValue("intensity"), NumberStyles.Float, CultureInfo.InvariantCulture, out intensity);
bool hasSprite = true;
bool.TryParse(x.EntityData.GetPropertyValue("hassprite") ?? "true", out hasSprite);
bool hasSprite = parseBooleanProperty(x.EntityData.GetPropertyValue("hassprite") ?? "true");
float innerCos = 0.5f;
float.TryParse(x.EntityData.GetPropertyValue("innerconeangle"), NumberStyles.Float, CultureInfo.InvariantCulture, out innerCos);
innerCos = (float)Math.Cos(innerCos * (float)Math.PI / 180.0f);
Expand Down

0 comments on commit a00a6b3

Please sign in to comment.