Skip to content

Instantly share code, notes, and snippets.

@ClysmiC
Created January 15, 2022 01:52
Show Gist options
  • Save ClysmiC/b081c3fc0af41a72bf7405b4368c6ad7 to your computer and use it in GitHub Desktop.
Save ClysmiC/b081c3fc0af41a72bf7405b4368c6ad7 to your computer and use it in GitHub Desktop.
// NOTE - This file is auto-generated by hgen. DO NOT MODIFY!
// building_core.h
namespace Construction
{
inline fix64 HpStart(fix64 hpMax);
inline fix64 DHpPerSecond(fix64 hpMax, fix64 constructionTime);
} // namespace Construction
// entity.h
inline EntityRef GetRef(EntityHeader * header);
// game.h
inline bool IsActive(Editor * editor);
// player.h
internal void InitPlayer(Player * player, PlayerId playerId);
internal void InitLocalPlayer(LocalPlayer * localPlayer, PlayerId playerId);
// select.h
internal void InitSelection(Selection * selection, PlayerId playerId);
// ui.h
inline UiRelativePos UiPosFromBotLeft(Vec2 offset);
inline UiRelativePos UiPosFromBotRight(Vec2 offset);
inline UiRelativePos UiPosFromTopLeft(Vec2 offset);
inline UiRelativePos UiPosFromTopRight(Vec2 offset);
inline UiRelativePos UiPosFromP1(Vec2 offset);
inline UiRelativePos UiPosFromCenter(Vec2 offset);
// vtable.h
namespace VTABLE
{
inline void OnMemoryRelocate_Default_Nop(void * prevAddress, void * newAddress);
inline void InitPostSpawn_Default_Nop(void * entity, void * spawnRequest);
inline void PreUnspawn_Default_Nop(void * entity);
inline Vec2x CenterPosFromSpawnRequest_Default_Nil(void * spawnRequest);
} // namespace VTABLE
// command_card.cpp
internal bool IsCommandSlotValid(CommandSlot slot);
internal Hotkey GetCommandHotkey(GameState * gameState, CommandSlot slot);
internal CommandSlot InvalidCommandSlot();
internal CommandSlot GetBoundCommandSlot(GameState * gameState, Command command);
internal Hotkey GetCommandHotkey(GameState * gameState, Command command);
inline Command GetCommand(CommandCard * card, CommandSlot slot);
internal void SetCommandInSlot(CommandCard * card, Command command, CommandSlot slot);
internal void BuildCommandCard(GameState * gameState, CommandCard * card, Command * commands, int commandCount);
internal bool ShouldIssueCommand(CommandCard * card, Command query, Command clicked);
internal Command CommandFromPendingOrder(PendingOrder * pendingOrder);
internal Command GetDisplayCommandFromOrderType(OrderType type);
internal Command UpdateAndRenderCommandCard(IMM::Ctx * immUi, UiCards * uiCards, RenderPass * renderPass, f32 kScaleGame, CommandCard * oCard);
// entity.cpp
internal int SizeOf(EntityType type);
template <typename E> internal E * Get(EntityHeader * entity);
template <typename E> internal E * GetUnchecked(EntityHeader * entity);
internal u32 GetRawSubType(EntityHeader * entity);
// game.cpp
internal bool IsClientWindowValid(GameInput * gameInput);
internal void SetScreenRegion(ScreenRegion * region, Rect2 rectPx, f32 kScale=1.0f);
internal void SetScreenRegion(ScreenRegion * region, int x0, int y0, int widthPx, int heightPx, f32 kScale=1.0f);
internal Vec2x ClampPosToMapBoundary(World * world, Vec2x pos);
internal Vec2 ClampPosToMapBoundary(World * world, Vec2 pos);
internal void EndOfFrameProcessUnit(Unit * unit, EntityIterator * iterator);
internal void EndOfFrameProcessBuilding(Building * building);
internal void MoveUnit(Unit * unit, Vec3x newPos);
internal void ClearAllUnitsScratchSpace(World * world);
internal void ClearAllBuildingsScratchSpace(World * world);
internal Vec2x GetSpawnLocation(World * world, Building * building, fix64 newUnitRadius);
internal HeightAndAngle GetZoomInfo(int zoomLevel);
inline void SetCamera(Camera * camera, Vec3 pos, Vec3 viewDir, Vec3 upHintDir=Vec3(0, 0, 1));
inline void SetCamera(Camera * camera, Vec3 pos, f32 yaw, f32 pitch);
inline void SetGameCamera(GameCamera * gameCam, Vec2 target, int zoomLevel=-1);
internal Vec2 GetCameraTarget(Camera * camera);
internal bool TryRepositionGameCameraOnControlGroup(GameCamera * gameCam, Selection * selection, ControlGroupIndex iControlGroup);
inline void SetOrthoProjection(ProjectionParams * projection, f32 height, f32 aspectRatio, f32 nearDist, f32 farDist);
inline void SetPerspectiveProjection(ProjectionParams * projection, f32 fovVertical, f32 aspectRatio, f32 nearDist, f32 farDist);
inline Mat4 ProjectionMatrix(ProjectionParams * projection);
inline Mat4 ViewMatrix(Camera * camera);
internal Vec2x SteerSeek(Unit * unit, Vec2x target);
internal Vec2x SteerArrive(Unit * unit, Vec2x target, fix64 approachRadius);
internal Vec2x SteerSeparate(UnitClumpTable * clumpTable, Unit * unit, UnitNeighborhood * neighborhood);
internal Vec2x SteerCohere(Unit * unit, UnitNeighborhood * neighborhood);
internal fix64 SteerAlign(Unit * unit, iangle target, fix64 dTDesiredOrientation);
internal bool IsSettledInClump(Unit * unit);
internal bool IsAtTargetEntity(Unit * unit);
internal Vec3 ZCylinderSupport(Vec3 posBase, f32 radius, f32 height, Vec3 support);
internal Vec3 Rect3Support(Rect3 rect, Vec3 support);
internal void SetCursorState(GameState * gameState, GameInput * gameInput, CursorState cursorState);
internal void UpdateCursorState(GameState * gameState, GameInput * gameInput);
internal void SetEditorState(GameState * gameState, GameInput * gameInput, EditorState state);
internal void UpdateEditor(GameState * gameState, GameInput * gameInput);
internal void ComputeScreenRegionsAndUiCards(GameScreenRegions * screenRegions, UiCards * uiCards, int clientWidthPx, int clientHeightPx, bool isClientWindowValid, bool isEditorActive);
internal void SetupProjection(ProjectionParams * gameProjectionParams, ProjectionParams * editorProjectionParams, GameScreenRegions * screenRegions, UserInput * userInput);
internal void StartOfFrameSetupRenderPasses(GameState * gameState, RenderCmds * renderCmds, Mat4 gameView, Mat4 gameProj, Mat4 gameViewProj, Vec3 camPosWorld);
internal void ClearGpuState(UiFrameImages * images);
internal void ClearGpuState(UiButtonImages * images);
internal void OnDllHotload(GameInput * gameInput, GameState * gameState);
internal void InitEditor(Editor * editor, RenderPass * renderPass, Vec2 clientDimPx);
internal void InitGameState(GameState * gameState, GameInput * gameInput, fix64 worldWidthMeters, fix64 worldHeightMeters);
internal void InitWorld(World * world, MemoryRegion worldMemory, uint worldWidthTiles, uint worldHeightTiles, fix64 worldWidthMeters, fix64 worldHeightMeters);
internal void InitPlatform(PlatformCode * platform, LoadedImage * whiteTexture);
internal void OnStartup(GameInput * gameInput, GameOutput * gameOutput);
inline LocalPlayer * GetLocalPlayer();
inline LocalPlayer * GetLocalPlayerFor(PlayerId playerId);
internal void SetLocalPlayer(GameState * gameState, PlayerId newLocalId);
internal void SpawnStartingUnits(PlayerId playerId, Vec2x posTownHallCenter, bool mineralsOnLeft);
// image.cpp
internal PixelsAndStride ComputeOppositePixelsAndStride(PixelsAndStride pixelsAndStride, int widthPx, int heightPx);
internal LoadedImage MakeEmptyImage(MemoryRegion memory, u32 widthPx, u32 heightPx, CTZ ctz=CTZ::Nil);
internal LoadedImage DebugLoadImage(char * filename);
// imm.cpp
namespace IMM
{
inline bool AreEqual(IdPath * path0, IdPath * path1);
inline void ClearPath(IdPath * path);
inline RegionBuildState * CurrentRegionBuildState(Ctx * immUi);
inline bool CanInteract(Primitive primitive);
inline bool IsHovered(Ctx * immUi, IdPath * path);
inline bool IsCurrentHovered(Ctx * immUi);
inline bool IsHoverRequested(Ctx * immUi, IdPath * path);
inline bool IsCurrentHoverRequested(Ctx * immUi);
inline void RequestCurrentHovered(Ctx * immUi, CursorKind cursorOverride=CursorKind::Nil);
inline void SetCursorOverrideIfCurrentHoverRequested(Ctx * immUi, CursorKind cursor);
inline bool IsDumbHovered(Ctx * immUi, IdPath * path);
inline bool IsCurrentDumbHovered(Ctx * immUi);
inline bool IsDumbHoverRequested(Ctx * immUi, IdPath * path);
inline bool IsCurrentDumbHoverRequested(Ctx * immUi);
inline void RequestCurrentDumbHovered(Ctx * immUi, CursorKind cursorOverride=CursorKind::Nil);
inline void SetCursorOverrideIfCurrentDumbHoverRequested(Ctx * immUi, CursorKind cursor);
inline bool IsActive(Ctx * immUi, IdPath * path);
inline bool IsCurrentActive(Ctx * immUi);
inline void RequestCurrentActive(Ctx * immUi);
inline void DebugRegion(Ctx * immUi);
inline RegionBuildState * PushRegion(Ctx * immUi, RegionParams params, Primitive primitive=Primitive::Region);
inline void PopRegion(Ctx * immUi);
internal void WindowTitlebar(Ctx * immUi, WindowTitleBarParams titleBarParams, Vec4 color);
internal void WindowResizeHandle(Ctx * immUi, WindowResizeHandleParams handle);
internal RegionBuildState * PushButton(Ctx * immUi, RegionParams params, UiButtonImages * uiImages, ButtonFlags flags, f32 kScale, bool * oClicked);
internal void PopButton(Ctx * immUi);
inline FlexLayout MakeFlexLayout(int cellCnt, DimSpecifier * mapICellToDimSpecifier, u8 flowDir);
inline Id DefaultNextId(Ctx * immUi);
internal RegionParams DefaultNextParams(Ctx * immUi, Id id=0);
inline Layout DefaultLayout();
inline Layout GridLayout(int rows, int cols, f32 interiorSpacing, f32 exteriorSpacing, GridFlowDir flowDir=GridFlowDir::LR_TB);
inline Layout FlexColumnsLayout(int columnCnt, DimSpecifier * mapIColumnToDimSpecifier, HFlowDir flowDir=HFlowDir::L_R);
inline Layout FlexRowsLayout(int rowCnt, DimSpecifier * mapIRowToDimSpecifier, VFlowDir flowDir=VFlowDir::T_B);
inline Layout FixedColumnsLayout(f32 columnWidth, HFlowDir flowDir=HFlowDir::L_R);
inline Layout FixedRowsLayout(f32 rowHeight, VFlowDir flowDir=VFlowDir::T_B);
internal WindowParams DefaultNextWindowParams(Ctx * immUi, Layout contentLayout=DefaultLayout(), Id id=0);
inline bool IsSubPathOf(IdPath * candidateSubPath, IdPath * path);
inline bool IsProperSubPathOf(IdPath * candidateSubPath, IdPath * path);
inline void PopWindow(Ctx * immUi);
inline void Begin(Ctx * immUi, RenderPass * renderPass, Vec2 dim, MouseInputState mouse, GlobalFlags flags=GlobalFlags::Nil);
inline EndOfFrameState End(Ctx * immUi);
internal void PushWindow(Ctx * immUi, WindowParams * windowParams, UiFrameImages * frameImages, WindowFlags flags=WindowFlags::Nil, f32 kScale=1.0f);
internal void FilledRect(Ctx * immUi, RegionParams params, Vec4 color);
internal void UiString(Ctx * immUi, RegionParams params, Font * font, String string, StringFlags flags= StringFlags::Nil, f32 kScale=1.0f);
internal void UiIcon(Ctx * immUi, RegionParams params, LoadedImage * icon, f32 kScale= 1.0f);
internal bool Button(Ctx * immUi, RegionParams params, UiButtonImages * uiImages, LoadedImage * icon=nullptr, ButtonFlags flags=ButtonFlags::Nil, f32 kScale=1.0f);
internal bool Button(Ctx * immUi, RegionParams params, UiButtonImages * uiImages, Font * font, String string, ButtonFlags flags=ButtonFlags::Nil, f32 kScale=1.0f);
internal bool CheckBox(Ctx * immUi, RegionParams params, Font * font, String label, LoadedImage * uncheckedImage, LoadedImage * checkedImage, bool * isChecked);
internal void TextInput(Ctx * immUi, RegionParams params, Font * font, String string);
} // namespace IMM
// mesh_import.cpp
internal Mesh ImportMeshOpenGex(OpenGex::OpenGexResult * openGex, MemoryRegion memory);
internal Mesh ImportMeshOpenGex(char * filename, MemoryRegion memory);
internal Mesh ImportMeshObj(Obj::ObjResult * obj, String mtlSearchDir, MemoryRegion memory);
internal Mesh ImportMeshObj(char * filename, MemoryRegion memory);
// order.cpp
internal QueuedOrders * AllocQueuedOrders();
internal void FreeQueuedOrders(QueuedOrders * queuedOrders);
inline Order * GetOrder(OrderList * orderList, int i);
inline Order * GetOrder(Unit * unit, int i);
inline Order * GetActiveOrder(Unit * unit);
internal void RemoveOrder(OrderList * orderList, int iOrder);
internal void RemovePpr(OrderList * orderList, int iPpr);
internal Unit * GetUnit(OrderTarget target);
inline Unit * GetUnitUnchecked(OrderTarget target);
internal Building * GetBuilding(OrderTarget target);
inline Building * GetBuildingUnchecked(OrderTarget target);
internal Resource * GetResource(OrderTarget target);
inline Resource * GetResourceUnchecked(OrderTarget target);
template <typename T> internal T * Get(OrderTarget * target);
template <typename T> internal T * GetUnchecked(OrderTarget * target);
inline EntityHeader * GetEntityChecked(OrderTarget target);
internal bool IsTargetValid(OrderTarget target);
inline OrderSrcType QueueifySource(OrderSrcType src);
internal void CleanupOrderWhenNoLongerExists(EntityHeader * entity, Order * order, bool wasActive);
internal void SetOrderListCount(EntityHeader * entity, OrderList * orderList, int count);
internal void SetPprCount(OrderList * orderList, int count);
inline bool ShouldStopUnit(OrderType type);
inline void StopUnit(Unit * unit);
inline bool IsUnitStopped(Unit * unit);
internal void SetActiveOrder(Unit * unit, Order order);
inline void SetOrderTarget(OrderTarget * target, Vec2x pos);
inline void SetOrderTarget(OrderTarget * target, Unit * unit);
inline void SetOrderTarget(OrderTarget * target, Building * building);
inline void SetOrderTarget(OrderTarget * target, Resource * resource);
inline bool HasMoreQueueCapacity(OrderList * orderList);
inline bool HasPendingPatrolReversals(OrderList * orderList);
inline bool HasMorePprCapacity(OrderList * orderList);
internal Order * TryEnqueueNew(OrderList * orderList);
internal Order * TryEnqueueNewPpr(OrderList * orderList);
internal Order * GetLastPpr(OrderList * orderList);
inline void ClearPendingOrder(PendingOrder * order);
inline bool HasQueuedOrders(OrderList * orderList);
internal Order * GetLastOrder(OrderList * orderList);
internal bool EndsWithPatrol(OrderList * orderList);
inline bool IssuePatrolOrder(Unit * unit, Vec2x targetPos, OrderSrcType source, bool queue);
inline bool IssueMoveOrder(Unit * unit, OrderTarget target, OrderSrcType source, bool queue);
inline bool IssueIdleAtTargetOrder(Unit * unit, OrderTarget target);
inline bool IssueRequestHoldPositionOrder(Unit * unit, bool queue);
inline void PromoteToHoldPosition(Unit * unit);
inline bool IssuePlaceBuildingOrder(GameState * gameState, Unit * unit, BuildingType type, TileCoord tileMin, BuildingParams * params, bool queue);
inline bool IssueBuildBuildingOrder(Unit * unit, Building * building);
inline bool IssueHarvestOrder(Unit * unit, Resource * resource);
internal void CompleteOrder(Unit * unit, Order * hotSwap=nullptr);
internal void ClearQueuedHoldPosition(Unit * unit);
internal Order * IssueOrderInternal(Unit * unit, OrderType type, OrderTarget target, OrderSrcType source, bool queue);
inline bool CanIssueOrderThroughMinimap(OrderType type);
internal bool IsSameTarget(OrderTarget t0, OrderTarget t1);
internal Vec2x GetOrderTargetPos(OrderTarget target, Vec2x * noneLocation);
internal void DropQueueAndCompleteOrder(Unit * unit);
inline bool IsRallyingToSelf(Building * building);
internal Vec2x GetOrderTargetPos(Order * order, Vec2x * noneLocation);
internal Vec2x GetOrderTargetPos(Unit * unit);
internal Vec2x EstimateFinalOrderTargetPos(Unit * unit);
inline fix64 EtaOrderComplete(Unit * unit, Order * order, Vec2x estimatedStartPos, bool allowPatrolButTruncate=false);
inline fix64 EtaAllOrdersComplete(Unit * unit, bool truncatePatrol);
internal void OrderUnitAfterFinishedHarvesting(World * world, Unit * unit, Resource * resource);
internal void OrderUnitAfterArrivingAtOccupiedMineralNode(World * world, Unit * unit, Resource * resource);
internal void DistributeSelectedWorkersToResources(Selection * selection, Vec2 pos, f32 radius, bool queue);
internal fix64 OrderDisplacementSq(Unit * unit);
// render_core.cpp
inline void EnableRenderPass(RenderPass * renderPass, RenderPassName name, Mat4 view, Mat4 projection, Vec3 camPosWorld, RenderTargetName target, bool isUiPass, bool depthTest, bool wireframe);
inline void ConfigureLighting(RenderPass * renderPass, LightingConfiguration lighting);
inline void DisableRenderPass(RenderPass * renderPass);
template <typename T> inline T * PushEntry_(RenderPass * renderPass, RenderEntryType type);
internal void PushClear(RenderPass * renderPass, Vec4 color);
internal void PushFilledRect2D(RenderPass * renderPass, SignedAxis normal, Vec3 posCenter, Vec2 dim, Vec4 color);
internal void PushOutlinedRect2D(RenderPass * renderPass, SignedAxis normal, Vec3 posCenter, Vec2 dim, Vec4 color, f32 outlineThickness);
internal void PushUiFilledRect2D(RenderPass * renderPass, Vec2 posCenter, Vec2 dim, Vec4 color, Rect2 clipRect=RectFromCenterDim(Vec2Fill(0), 100000));
internal void PushUiFilledRect2D(RenderPass * renderPass, Rect2 rect, Vec4 color, Rect2 clipRect=RectFromCenterDim(Vec2Fill(0), 100000));
internal void PushUiOutlinedRect2D(RenderPass * renderPass, Vec2 posCenter, Vec2 dim, Vec4 color, f32 outlineThickness, Rect2 clipRect=RectFromCenterDim(Vec2Fill(0), 100000));
internal void PushUiOutlinedRect2D(RenderPass * renderPass, Rect2 rect, Vec4 color, f32 outlineThickness, Rect2 clipRect=RectFromCenterDim(Vec2Fill(0), 100000));
internal void PushFilledCircle2D(RenderPass * renderPass, SignedAxis normal, Vec3 posCenter, f32 radius, Vec4 color);
internal void PushFilledRect3D(RenderPass * renderPass, Vec3 v0, Vec3 v1, f32 rotZ, Vec4 color);
internal void PushUnlitFilledRect3D(RenderPass * renderPass, Vec3 v0, Vec3 v1, f32 rotZ, Vec4 color);
internal void PushCylinder(RenderPass * renderPass, Vec3 posCenter, f32 radius, f32 height, Vec4 color);
internal void PushLine(RenderPass * renderPass, Vec3 pos0, Vec3 pos1, Vec4 color);
internal void PushTexturedQuad(RenderPass * renderPass, Vec3 posOrigin, Vec3 uAxis, Vec3 vAxis, LoadedImage * texture, TextureParams textureParams=DefaultTextureParams());
internal void PushTexturedQuad(RenderPass * renderPass, Vec3 posOrigin, Vec3 uAxis, Vec3 vAxis, RenderTargetName textureSrc, TextureParams textureParams=DefaultTextureParams());
internal void PushMesh(RenderPass * renderPass, Mesh * mesh, Vec3 pos, f32 rotZ, RenderEntrySubmesh::TintParams tintParams=DefaultTintParams());
internal void PushUiString(RenderPass * renderPass, Vec2 posOrigin, Font * font, String string);
internal void PushUiFrame(RenderPass * renderPass, UiFrameImages * uiFrameImages, Vec2 min, Vec2 max, UiFrameRegionDescription frameRegionDescription, f32 kScale=1.0f);
internal void PushFilledUiFrame(RenderPass * renderPass, UiFrameImages * uiFrameImages, Vec2 min, Vec2 max, Vec4 fillColor, UiFrameRegionDescription frameRegionDescription, f32 kScale=1.0f);
// building.cpp
internal bool CanResumeBuildingAt(Unit * unit, Building * building);
internal bool CanDepositPayloadAt(Unit * unit, Building * building);
internal Unit * GetBuilder(World * world, Building * building);
internal BuildingPlacementGhost * AllocBuildingPlacementGhost(GameState * gameState);
internal void FreeBuildingPlacementGhost(World * world, BuildingPlacementGhost * bpg);
internal void OnMemoryRelocate(Building * prevAddress, Building * newAddress);
inline void InitPostSpawn(Building * building, SpawnBuildingRequest * spawnRequest);
internal void PreUnspawn(Building * building);
internal Vec2x CenterPosFromSpawnRequest(SpawnBuildingRequest * spawnRequest);
inline Vec2x GetCenterPos(Building * building);
inline TileRect GetTileRect(Building * building);
inline Rect2x GetWorldRect(Building * building);
inline Rect3 GetWorldRect3(Building * building);
inline bool IsConstructionComplete(Building * building);
inline fix64 UConstructionComplete(Building * building);
inline void CompleteConstruction(ConstructionState * constructionState, fix64 constructionTime);
inline void CompleteConstruction(Building * building);
// input.cpp
inline bool EndedDown(DigitalInputState input);
inline bool EndedDown(UserInput * userInput, Hotkey hotkey);
inline bool StartedDown(DigitalInputState input);
inline bool StartedDown(UserInput * userInput, Hotkey hotkey);
inline bool WasOnlyDown(DigitalInputState input);
inline bool WasOnlyDown(UserInput * userInput, Hotkey hotkey);
inline bool WasOnlyUp(DigitalInputState input);
inline bool WasOnlyUp(UserInput * userInput, Hotkey hotkey);
inline bool WasEverDown(DigitalInputState input);
inline bool WasEverDown(UserInput * userInput, Hotkey hotkey);
inline bool WasEverUp(DigitalInputState input);
inline bool WasEverUp(UserInput * userInput, Hotkey hotkey);
inline bool WasEverPressed(DigitalInputState input);
inline bool WasEverPressed(UserInput * userInput, Hotkey hotkey);
inline bool WasEverReleased(DigitalInputState input);
inline bool WasEverReleased(UserInput * userInput, Hotkey hotkey);
inline void ConsumeInputEdge(DigitalInputState * input);
// minimap.cpp
internal void UpdateAndRenderMinimapCard(IMM::Ctx * immUi, UiCards * uiCards, RenderPass * renderPass, f32 kScaleGame= 1.0f);
// raycast.cpp
inline f32 TimeToReachCoordinatePreDivided(f32 pos, f32 invDir, f32 target);
inline TimeToReachCoordinateResult TimeToReachCoordinate(f32 pos, f32 dir, f32 target);
internal RaycastResult RayVsXYPlaneAtHeight(Ray3 ray, f32 heightZ);
internal RaycastResult RayVsCircle(Ray2 ray, Vec2 posCenter, f32 radius);
internal RaycastResult RayVsZCylinder(Ray3 ray, Vec3 posBase, f32 radius, f32 height, bool skipBottomFace=false);
internal RaycastResult RayVsRect3(Ray3 ray, Rect3 rect);
internal RaycastResult RayVsRect2(Ray2 ray, Rect2 rect);
inline fix64 TimeToReachCoordinatePreDivided(fix64 pos, fix64 invDir, fix64 target);
inline TimeToReachCoordinateResultX TimeToReachCoordinate(fix64 pos, fix64 dir, fix64 target);
internal RaycastResultX RayVsXYPlaneAtHeight(Ray3x ray, fix64 heightZ);
internal RaycastResultX RayVsCircle(Ray2x ray, Vec2x posCenter, fix64 radius);
internal RaycastResultX RayVsZCylinder(Ray3x ray, Vec3x posBase, fix64 radius, fix64 height, bool skipBottomFace=false);
internal RaycastResultX RayVsRect3(Ray3x ray, Rect3x rect);
internal RaycastResultX RayVsRect2(Ray2x ray, Rect2x rect);
// render_game.cpp
internal void PushBuilding(RenderPass * renderPass, BuildingType type, TileCoord tileMin, f32 uComplete, bool isSelected, bool isHovered, Vec4 color);
internal void PushGhostBuilding(RenderPass * renderPass, BuildingType type, TileCoord tileMin);
inline void PushResource(RenderPass * renderPass, Resource * resource, RenderEntrySubmesh::TintParams tintParams=DefaultTintParams());
internal void PushUnitOrders(RenderPass * renderPass, Unit * unit);
internal void PushRallyOrders(RenderPass * renderPass, Building * building);
internal void PushTerrain(RenderPass * renderPass, GameState * gameState, World * world);
internal void PushHealthBar(RenderPass * renderPass, Vec3 posWorld, fix64 hp, fix64 hpMax, Mat4 viewProj, Vec2 screenDimPx);
internal void RenderSimulation(GameState * gameState, MousePosInfo * mousePosInfo, RenderPass * simPass, RenderPass * simOverlayPass, RenderPass * simUiPass, Vec2 screenDimPx, Rect2x simRect);
internal void RenderMinimapTexture(RenderPass * minimapRenderPass, GameState * gameState, MousePosInfo * mousePosInfo, Vec3 * mpSimClientCornerToPosWorld);
internal void RenderResourceCounts(IMM::Ctx * immUi, Player * player);
inline Rect2 TopLeftCornerRegion(Rect2 outerRect, f32 width, f32 height);
internal void RenderPlayerName(IMM::Ctx * immUi, Player * player);
internal void RenderDragSelection(GameState * gameState, RenderPass * renderPass, Vec2 mousePosGamePx);
internal void RenderEditorPip(RenderPass * renderPass, GameState * gameState);
internal void RenderFrustum(RenderPass * renderPass, Camera * camera, ProjectionParams * projectionParams, Vec4 color);
// resource.cpp
internal void SetActiveResource(Unit * worker, Resource * resource);
inline bool IsHarvestingResource(Unit * unit);
inline bool HasResourcePayload(Unit * unit);
internal void InitPostSpawn(Resource * resource, SpawnResourceRequest * spawnRequest);
internal Vec2x CenterPosFromSpawnRequest(SpawnResourceRequest * spawnRequest);
inline Vec2x GetCenterPos(Resource * resource);
inline TileRect GetTileRect(Resource * resource);
inline Rect2x GetWorldRect(Resource * resource);
inline Rect3 GetWorldRect3(Resource * resource);
// screen.cpp
internal ViewBounds ComputeViewBounds(GameInput * gameInput, Camera * camera, ProjectionParams * projectionParams, Vec2 viewDimPx, f32 minYPx);
internal Vec3 PosScreenFromWorld(Mat4 viewProj, Vec3 posWorld, Vec2 clientDimPx);
internal Ray3 RayThroughPixel(Vec2 posClientPx, Vec2 clientDimPx, Camera * camera, ProjectionParams * projection);
// select.cpp
internal EntityHeader * GetEntity(Selectable * selectable);
internal Unit * GetUnit(Selectable * selectable);
inline Unit * GetUnitUnchecked(Selectable * selectable);
internal Building * GetBuilding(Selectable * selectable);
inline Building * GetBuildingUnchecked(Selectable * selectable);
inline bool IsSelected(Selectable * selectable);
inline bool IsSelected(Unit * unit);
inline bool IsSelected(Building * building);
internal void Select(Selection * selection, Selectable * selectable, bool userInitiated=true);
internal void Select(Selection * selection, Unit * unit, bool userInitiated=true);
internal void Select(Selection * selection, Building * building, bool userInitiated=true);
internal bool CanSelectionPerformPendingOrder(Selection * selection);
internal void Deselect(Selection * selection, Selectable * selectable, bool userInitiated=true);
internal void Deselect(Selection * selection, Unit * unit, bool userInitiated=true);
internal void Deselect(Selection * selection, Building * building, bool userInitiated=true);
internal void DeselectAll(Selection * selection);
internal bool IsInControlGroup(Selectable * selectable, ControlGroupIndex iControlGroup);
internal bool IsInControlGroup(Unit * unit, ControlGroupIndex iControlGroup);
internal bool IsInControlGroup(Building * building, ControlGroupIndex iControlGroup);
internal void AddToControlGroup(Selection * selection, Selectable * selectable, ControlGroupIndex iControlGroup);
internal void AddToControlGroup(Selection * selection, Unit * unit, ControlGroupIndex iControlGroup);
internal void AddToControlGroup(Selection * selection, Building * building, ControlGroupIndex iControlGroup);
internal void RemoveFromControlGroup(Selection * selection, Selectable * selectable, ControlGroupIndex iControlGroup);
internal void RemoveFromControlGroup(Selection * selection, Unit * unit, ControlGroupIndex iControlGroup);
internal void RemoveFromControlGroup(Selection * selection, Building * building, ControlGroupIndex iControlGroup);
internal void RemoveFromAllControlGroups(Selection * selection, Selectable * selectable);
internal void RemoveFromAllControlGroups(Selection * selection, Unit * unit);
internal void RemoveFromAllControlGroups(Selection * selection, Building * building);
internal void ClearControlGroup(Selection * selection, ControlGroupIndex iControlGroup);
internal bool TrySelectControlGroup(Selection * selection, ControlGroupIndex iControlGroup);
internal void ClearSelectablePerFrameData(Selectable * selectable);
internal void UpdateAndRenderSelectionCard(IMM::Ctx * immUi, UiCards * uiCards, RenderPass * renderPass, f32 kScaleGame=1.0f);
// tile.cpp
internal Rect2x WorldRectFromTileRect(TileRect rect);
internal int ComputeMinTileCoord(fix64 coordCenter, int placementDim);
inline bool HasPositiveArea(TileRect rect);
internal TileRect TileRect_CenterDim(Vec2x posCenter, Vec2i dimTiles);
inline TileRect TileRect_MousePosInfo(MousePosInfo mousePosInfo, Vec2i dimTiles, bool forcePunchThroughUi=false);
internal TileRect InflateAndClampToWorld(TileRect rect, int inflateRadius);
internal bool CheckPlacementValidAgainstOther(TileRect self, TileRect other, bool * oTilesValid=nullptr);
internal bool CheckPlacementValidity(World * world, TileRect rect, bool * oTilesValid=nullptr);
internal bool TestUnitOverlapsTileRect(Unit * unit, TileRect rect);
// ui.cpp
internal void InitUi(UiManager * uiMgr, MemoryRegion memory);
internal void UiStartTick(UiManager * uiMgr, MouseInputState * mouse, Vec2 clientDimPx, f32 timestamp);
inline bool IsDepthPlaneRoot(UiControl * control);
internal void DetectHovered_(UiManager * uiMgr, ActiveUiControl * ioResult);
internal void DetectClicked_(UiManager * uiMgr, ActiveUiControl * ioResult);
internal void DetectHeld_(UiManager * uiMgr, ActiveUiControl * ioResult);
internal ActiveUiControl ProcessInputRecursive_(UiManager * uiMgr, UiControl * control);
internal void ProcessInput_(UiManager * uiMgr);
inline bool IsRootControl(UiControl * control);
internal Rect2 ComputeRectAbs_(Rect2 parentRectAbs, UiRelativePos p0, UiRelativePos p1);
internal void RefreshRect_(UiControl * control);
internal void SetRect_(UiControl * control, UiRelativePos p0, UiRelativePos p1);
internal void ResizeCorners_(UiControl * control, Vec2 dP0, Vec2 dP1);
internal UiControl * BeginControl(UiManager * uiMgr, UiId id, UiRelativePos p0, UiRelativePos p1, Vec4 rgba, UiFlags flags=UiFlags::Nil, UiDepthPlaneMode depthMode=UiDepthPlaneMode::Nil);
internal void AttachExistingDepthPlane(UiControl * control, UiDepthPlane * depthPlane);
internal void AttachNewDepthPlane(UiManager * uiMgr, UiControl * control, UiDepthPlaneMode depthMode);
internal void EndControl(UiManager * uiMgr);
internal UiControl * DoLeafControl(UiManager * uiMgr, UiId id, UiRelativePos p0, UiRelativePos p1, Vec4 rgba, UiFlags flags=UiFlags::Nil);
internal void LayoutUi(UiManager * uiMgr);
internal Vec2 LayoutControlRecursive_(UiManager * uiMgr, UiControl * control, bool forceRefresh);
internal Vec2 ComputeParentDimRequired(UiRelativePos p, UiRelativePos * posPrev=nullptr);
inline Rect2 GetParentRectAbsSafe(UiControl & control);
inline void GetUiAnchorsAbs(UiControl & control, Vec2 * oAnchor0Abs, Vec2 * oAnchor1Abs);
internal void RecycleDeadControlRecursive_(UiManager * uiMgr, UiControl * control);
internal CursorKind RenderUi(UiManager * uiMgr, RenderPass * renderPass);
inline bool IsActiveControl(UiManager * uiMgr, UiControl * control);
inline bool IsHovered(UiManager * uiMgr, UiControl * control);
inline bool IsClicked(UiManager * uiMgr, UiControl * control);
inline bool IsHeld(UiManager * uiMgr, UiControl * control);
inline DirFlags ResizeDirHeld(UiManager * uiMgr, UiControl * control);
internal void RenderControlRecursive_(UiManager * uiMgr, UiControl * control, RenderPass * renderPass);
internal int CompareDepthInSameDepthPlane_(UiControl * c0, UiControl * c1);
internal void UiEndTick(UiManager * uiMgr);
internal UiControl * FindControl(UiControl * list, UiId id);
inline bool IsAliveThisFrameAndPreviousFrame(UiManager * uiMgr, UiControl * control);
inline void GetRelativeRectAndParentBounds(UiControl * control, Rect2 * oRectRel, Vec2 * oParentBounds);
// ui_card.cpp
internal void UpdateAndRenderUiCards(IMM::Ctx * immUi, GameScreenRegions * screenRegions, CommandCard * oCard, Command * oClicked);
// unit_clump.cpp
internal UnitClump * ClaimNextFreeClump(UnitClumpTable * table);
internal void DisposeClump(UnitClumpTable * table, UnitClump * clump);
internal void MergeClumpsAndDisposeSmaller(UnitClumpTable * clumpTable, UnitClump * clump0, UnitClump * clump1);
internal void RemoveFromClump(UnitClumpTable * clumpTable, Unit * unit);
internal void AddToClump(UnitClump * clump, Unit * unit);
internal void TryEnsureClumpNeighbors(Unit * u0, Unit * u1);
internal void ClearLastTrackedOrder(UnitClump * clump);
internal void HandleClumpNeighbors(UnitClumpTable * clumpTable, Unit * u0, Unit * u1);
internal UnitClumpDisplacementMetrics GetClumpDisplacementMetrics(UnitClump * clump);
// unit.cpp
inline void SetFacing(Unit * unit, Vec2x facingDir);
inline void SetFacing(Unit * unit, iangle facingAngle);
internal bool IsResourceWalking(Unit * unit);
internal void OnMemoryRelocate(Unit * prevAddress, Unit * newAddress);
internal void InitPostSpawn(Unit * unit, SpawnUnitRequest * spawnRequest);
internal void PreUnspawn(Unit * unit);
internal Vec2x CenterPosFromSpawnRequest(SpawnUnitRequest * spawnRequest);
// vtable.cpp
namespace VTABLE
{
internal void InitEntityVTables();
internal void OnDllLoad();
} // namespace VTABLE
// world.cpp
inline World::StorageFreeList & GetEntityStorageFreeList(EntityType type);
internal SpawnUnitRequest * TryRequestSpawnUnit(World * world, UnitType type, PlayerId playerId, Vec3x pos);
internal SpawnBuildingRequest * TryRequestSpawnBuilding(World * world, BuildingType type, PlayerId playerId, TileCoord tileMin, ConstructionState constructionState);
internal SpawnResourceRequest * TryRequestSpawnResource(World * world, ResourceType type, TileCoord tileMin);
template <typename E> internal E * Alloc(WorldChunk * chunk);
template <typename E> internal E * EndOfFrameSpawn(typename E::SpawnRequest_t * spawnRequest);
internal void RequestUnspawn(EntityHeader * entity);
internal void EndOfFrameUnspawn(UnspawnEntityRequest * request);
internal Building * GetNearestTownHall(World * world, Vec3x pos);
// world_chunk.cpp
inline WorldChunk::EntityStorageList & GetEntityStorageList(WorldChunk * chunk, EntityType type);
internal u32 HashEntityId(EntityId entityId);
internal EntityHeader * LookupEntity(EntityId id, EntityTable * table);
internal EntityHeader * LookupEntity(EntityId id);
internal EntityHeader * LookupEntity(EntityId id, EntityType type);
template <typename E> internal E * Lookup(EntityId entityId);
template <typename E> internal E * Lookup(typename E::Id_t id);
internal EntityTableEntry * AllocEntityTableEntry(EntityTable * table);
internal void FreeEntityTableEntry(EntityTable * table, EntityTableEntry * entry);
internal void AddEntityToTable(EntityTable * table, EntityHeader * entity);
internal bool TryRemoveEntityFromTable(EntityTable * table, EntityId entityId);
inline void Unspawn(EntityId id, EntityType type);
inline void Spawn(EntityHeader * entity);
inline void RelocateInMemory(EntityHeader * prevAddress, EntityHeader * newAddress, EntityStorage * newStorage);
internal EntityStorage * AllocStorage(EntityType type);
internal void FreeStorage(EntityStorage * storage, EntityType type);
internal WorldChunk * GetWorldChunk(World * world, int chunkX, int chunkY);
internal WorldChunk * GetWorldChunk(World * world, Vec2x pos);
internal WorldChunk * GetWorldChunk(World * world, Vec3x pos);
internal void MoveToNextEntity_(EntityIterator * iterator);
internal EntityIterator GlobalIterator(World * world, EntityType type);
internal EntityIterator RegionIterator(World * world, EntityType type, Vec2x min, Vec2x max);
internal EntityIterator RegionIterator(World * world, EntityType type, Rect2x rect);
internal Unit * NextUnit(EntityIterator * iterator);
internal Building * NextBuilding(EntityIterator * iterator);
internal Resource * NextResource(EntityIterator * iterator);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment