Second commit
This commit is contained in:
commit
36840f3ad4
999 files changed
+61364
No files matched your search
@@ -0,0 +1,73 @@
|
||||
//
|
||||
// This file is part of the Tremble package by Tiny Goose.
|
||||
// Copyright (c) 2024-2026 TinyGoose Ltd., All Rights Reserved.
|
||||
//
|
||||
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
namespace TinyGoose.Tremble
|
||||
{
|
||||
public enum CheckerboardStyle
|
||||
{
|
||||
None,
|
||||
Light,
|
||||
Dark,
|
||||
}
|
||||
|
||||
public enum BrushType
|
||||
{
|
||||
// Solid brush with a texture (default)
|
||||
Solid,
|
||||
|
||||
// Liquid brush (trigger collision) with a texture
|
||||
Liquid,
|
||||
|
||||
// An invisible brush which is a Unity trigger
|
||||
Trigger,
|
||||
|
||||
// An invisible (but solid) brush
|
||||
Invisible
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Marks this MonoBehaviour as a component which can be added to arbitrary Brush entities from a map.
|
||||
/// </summary>
|
||||
[AttributeUsage(AttributeTargets.Class)]
|
||||
public class BrushEntityAttribute : EntityAttributeBase
|
||||
{
|
||||
/// <summary>
|
||||
/// A Tremble-compatible Brush entity.
|
||||
/// </summary>
|
||||
/// <param name="trenchBroomName">The name in TrenchBroom. e.g. "cool_entity".</param>
|
||||
/// <param name="category">The category for TrenchBroom. e.g. "ent".</param>
|
||||
/// <param name="type">The brush type. e.g. Trigger, Solid, Liquid.</param>
|
||||
/// <param name="colour">The colour of this brush's texture.</param>
|
||||
/// <param name="checkerStyle">The type of checkerboard for this brush's texture.</param>
|
||||
/// <param name="layer">The layer name to put this brush on.</param>
|
||||
public BrushEntityAttribute(
|
||||
string trenchBroomName = null,
|
||||
string category = null,
|
||||
BrushType type = BrushType.Solid,
|
||||
string colour = "",
|
||||
CheckerboardStyle checkerStyle = CheckerboardStyle.None,
|
||||
string layer = "")
|
||||
: base(trenchBroomName, category)
|
||||
{
|
||||
m_BrushType = type;
|
||||
m_Colour = colour.TryParseQ3Colour(out Color value) ? value : null;
|
||||
m_CheckerStyle = checkerStyle;
|
||||
m_LayerName = layer;
|
||||
}
|
||||
|
||||
private readonly BrushType m_BrushType;
|
||||
private readonly Color? m_Colour;
|
||||
private readonly CheckerboardStyle m_CheckerStyle;
|
||||
private readonly string m_LayerName;
|
||||
|
||||
public BrushType BrushType => m_BrushType;
|
||||
public Color? Colour => m_Colour;
|
||||
public CheckerboardStyle CheckerStyle => m_CheckerStyle;
|
||||
public string LayerName => m_LayerName;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 36b1eeadd99b4fd9bfd817b15f131f87
|
||||
timeCreated: 1711702807
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 277805
|
||||
packageName: Tremble - Map Importer
|
||||
packageVersion: 1.11.1
|
||||
assetPath: Assets/Tremble/Attributes/Classes/BrushEntityAttribute.cs
|
||||
uploadId: 939664
|
||||
@@ -0,0 +1,26 @@
|
||||
//
|
||||
// This file is part of the Tremble package by Tiny Goose.
|
||||
// Copyright (c) 2024-2026 TinyGoose Ltd., All Rights Reserved.
|
||||
//
|
||||
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
namespace TinyGoose.Tremble
|
||||
{
|
||||
[AttributeUsage(AttributeTargets.Class)]
|
||||
public abstract class EntityAttributeBase : SelectionBaseAttribute
|
||||
{
|
||||
protected EntityAttributeBase(string trenchBroomName = null, string category = null)
|
||||
{
|
||||
m_TrenchBroomName = trenchBroomName.Sanitise();
|
||||
m_Category = category.Sanitise();
|
||||
}
|
||||
|
||||
private readonly string m_TrenchBroomName;
|
||||
private readonly string m_Category;
|
||||
|
||||
public string TrenchBroomName => m_TrenchBroomName;
|
||||
public string Category => m_Category;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 84c2d0a79b3844d98271142f9df938e3
|
||||
timeCreated: 1711702912
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 277805
|
||||
packageName: Tremble - Map Importer
|
||||
packageVersion: 1.11.1
|
||||
assetPath: Assets/Tremble/Attributes/Classes/EntityAttributeBase.cs
|
||||
uploadId: 939664
|
||||
@@ -0,0 +1,41 @@
|
||||
//
|
||||
// This file is part of the Tremble package by Tiny Goose.
|
||||
// Copyright (c) 2024-2026 TinyGoose Ltd., All Rights Reserved.
|
||||
//
|
||||
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
namespace TinyGoose.Tremble
|
||||
{
|
||||
/// <summary>
|
||||
/// Marks this MonoBehaviour as a component which can be added to empty GameObjects as a Point entity.
|
||||
/// </summary>
|
||||
[AttributeUsage(AttributeTargets.Class)]
|
||||
public class PointEntityAttribute : EntityAttributeBase
|
||||
{
|
||||
/// <summary>
|
||||
/// A Tremble-compatible Point entity.
|
||||
/// </summary>
|
||||
/// <param name="trenchBroomName">The name in TrenchBroom. e.g. "cool_entity".</param>
|
||||
/// <param name="category">The category for TrenchBroom. e.g. "ent".</param>
|
||||
/// <param name="colour">The colour of the entity in TrenchBroom. e.g. green is "0.0 1.0 0.0".</param>
|
||||
/// <param name="sprite">The sprite to show in TrenchBroom. Must be the name of a texture in your project. e.g. "T_MyTexture".</param>
|
||||
/// <param name="size">The size of the cube for this entity in TrenchBroom. e.g. 5.</param>
|
||||
public PointEntityAttribute(string trenchBroomName = null, string category = null, string colour = null, string sprite = null, float size = 0.25f)
|
||||
: base(trenchBroomName, category)
|
||||
{
|
||||
m_Size = size;
|
||||
m_Sprite = sprite;
|
||||
m_Colour = colour.TryParseQ3Colour(out Color value) ? value : Color.white;
|
||||
}
|
||||
|
||||
private readonly Color? m_Colour;
|
||||
private readonly string m_Sprite;
|
||||
private readonly float m_Size;
|
||||
|
||||
public Color Colour => m_Colour ?? Color.white;
|
||||
public string Sprite => m_Sprite;
|
||||
public float Size => m_Size;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ac6bd87f35f74bf6b78590e9038c0ee4
|
||||
timeCreated: 1711702870
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 277805
|
||||
packageName: Tremble - Map Importer
|
||||
packageVersion: 1.11.1
|
||||
assetPath: Assets/Tremble/Attributes/Classes/PointEntityAttribute.cs
|
||||
uploadId: 939664
|
||||
@@ -0,0 +1,71 @@
|
||||
//
|
||||
// This file is part of the Tremble package by Tiny Goose.
|
||||
// Copyright (c) 2024-2026 TinyGoose Ltd., All Rights Reserved.
|
||||
//
|
||||
|
||||
using System;
|
||||
|
||||
namespace TinyGoose.Tremble
|
||||
{
|
||||
/// <summary>
|
||||
/// Marks this MonoBehaviour as being usable as a Point entity in TrenchBroom, using one or more prefabs in the project.
|
||||
/// </summary>
|
||||
[AttributeUsage(AttributeTargets.Class)]
|
||||
public class PrefabEntityAttribute : EntityAttributeBase
|
||||
{
|
||||
/// <summary>
|
||||
/// A Tremble-compatible Prefab entity.
|
||||
/// </summary>
|
||||
/// <param name="trenchBroomName">The name in TrenchBroom. e.g. "P_MyPrefab".</param>
|
||||
/// <param name="category">The category for TrenchBroom. e.g. "game".</param>
|
||||
/// <param name="excludePrefabs">Which prefabs containing this script to exclude. e.g. "P_BaseCoinPrefab".</param>
|
||||
/// <param name="onlyIncludePrefabs">Which prefabs containing this script to include. e.g. "P_TrembleCoinPrefab".</param>
|
||||
/// <param name="excludePrefab">Which prefabs containing this script to exclude. e.g. "P_BasePrefab".</param>
|
||||
/// <param name="onlyIncludePrefab">Which prefabs containing this script to include. e.g. "P_TrembleCoinPrefab".</param>
|
||||
/// <param name="onlyVariants">Only export variants, not root prefabs</param>
|
||||
public PrefabEntityAttribute(string trenchBroomName = null, string category = null, string[] excludePrefabs = null, string[] onlyIncludePrefabs = null, string excludePrefab = null, string onlyIncludePrefab = null, bool onlyVariants = false, string overrideSprite = null)
|
||||
: base(trenchBroomName: trenchBroomName, category: category)
|
||||
{
|
||||
m_ExcludedPrefabNames = excludePrefab != null ? new [] { excludePrefab } : excludePrefabs;
|
||||
m_OnlyIncludedPrefabNames = onlyIncludePrefab != null ? new [] { onlyIncludePrefab } : onlyIncludePrefabs;
|
||||
|
||||
m_OverrideSprite = overrideSprite;
|
||||
m_OnlyVariants = onlyVariants;
|
||||
}
|
||||
|
||||
private readonly string[] m_ExcludedPrefabNames;
|
||||
private readonly string[] m_OnlyIncludedPrefabNames;
|
||||
|
||||
private readonly string m_OverrideSprite;
|
||||
private readonly bool m_OnlyVariants;
|
||||
|
||||
public bool IsPrefabIncluded(string prefabName)
|
||||
{
|
||||
// Is excluded explicitly?
|
||||
if (m_ExcludedPrefabNames != null)
|
||||
{
|
||||
foreach (string excluded in m_ExcludedPrefabNames)
|
||||
{
|
||||
if (excluded.ToSimpleRegex().IsMatch(prefabName))
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// Include everything?
|
||||
if (m_OnlyIncludedPrefabNames == null)
|
||||
return true;
|
||||
|
||||
// See if it's on the whitelist
|
||||
foreach (string included in m_OnlyIncludedPrefabNames)
|
||||
{
|
||||
if (included.ToSimpleRegex().IsMatch(prefabName))
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public string OverrideSprite => m_OverrideSprite;
|
||||
public bool OnlyVariants => m_OnlyVariants;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7573313e4df24673a7c5cbbc3763e392
|
||||
timeCreated: 1711702750
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 277805
|
||||
packageName: Tremble - Map Importer
|
||||
packageVersion: 1.11.1
|
||||
assetPath: Assets/Tremble/Attributes/Classes/PrefabEntityAttribute.cs
|
||||
uploadId: 939664
|
||||
@@ -0,0 +1,19 @@
|
||||
//
|
||||
// This file is part of the Tremble package by Tiny Goose.
|
||||
// Copyright (c) 2024-2026 TinyGoose Ltd., All Rights Reserved.
|
||||
//
|
||||
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace TinyGoose.Tremble
|
||||
{
|
||||
public static class SimpleRegexUtil
|
||||
{
|
||||
public static Regex ToSimpleRegex(this string pattern)
|
||||
{
|
||||
// This is overly simplistic. But essentially, changes a pattern like
|
||||
// "my*thing" into a Regex like "^my.+thing$"
|
||||
return new($"^{pattern.Replace("*", ".+")}$");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: eab674612dfd47fd833e72b6bbd5f974
|
||||
timeCreated: 1713786722
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 277805
|
||||
packageName: Tremble - Map Importer
|
||||
packageVersion: 1.11.1
|
||||
assetPath: Assets/Tremble/Attributes/Classes/SimpleRegexUtil.cs
|
||||
uploadId: 939664
|
||||
Reference in new issue
Block a user