Skip to content

Billboard Implementation Guide

Tsar edited this page Aug 14, 2024 · 13 revisions

Billboard Implementation Guide

Global guide on how to Implement a Billboard that updates based off of a set list of string parameters in Project OST.

Use this guide to learn how you can add your own stuff to Project OST

String parameters can be things like "[Name] or [Price]"... etc.

Example

image image

1. Create a new LogicalVisibility interface

Naviage to TycoonStomper/cc/ci.verse

This interface will be used to toggle the visibility of our BillboardDevice

  • Naviage to TycoonStomper/cc/ci.verse
  • Create a new interface called LogicalVisibility
  • Add 2 public Show and Hide methods

image

2. Create a new StringReturnables interface

This interface will be used to return a map of items such as "[Name]" => "{Name}" Later we'll build a function that takes this map and converts it to its real value.

  • Add a public GetStringParams method that returns a map of [string]string

image

3. Create a new StringInaugurable interface

This interface will be used to build out our billboard_main class and to define its StringReturnable list such as "[Name]" => "{Name}"

  • Add a public Initialize Method that takes a StringReturnableInterface

image

4. Create a new GetStringParamters function

Navigate to TycoonStomper/cc/cf.verse

  • This function will be used to fetch [string]string values from anything wtih the StringReturnable interface implemented.

  • This will then convert these values to their real values. I.e Input: "Hi I'm [Base]" => Output: "Hi I'm ExampleBaseNameHere"

  • Lets plan out how we'll create this function.

  • First we need to find every [] inside a string, then fetch the StringReturnables map and get the Value assocaited with the Key we found between the []

  • For example if the value between the brackets is Name then we need to go to our StringReturnable map and input Name as the Key

  • Then if there is an associated value to this Key we'll then replace whats inside the brackets with this value

  • Then we need to delete the brackets [] and update our current string value.

  • If we can no longer find any [] then we'll simply return the current string value.

My implementation

A

Explanation

  • I set a CurrentString variable so I can modify the all current outputs
  • I then check and ensure the string length is >= 1 so our other if's wont fail
  • Then I get the StringReturnables interface implementation and check the params.
  • For example if a base was parsed it would return something like {"[Name]"=>Name, "[ID]"=>UniqueID, "[Players.Length]"=>"{Players.Length}", "SizeLimit"=>"{SizeLimit}", "[Status]"=>"{Status.ToStr()}"} remember you can only parse something that implements the StringReturnables interface like a base purchaseable.
  • Next I loop and check for any chars' that have "[" or "]" .Find method returns the first index.
  • Then I slice a new array from the start of [ and then end of ]+1 since the end value prior to the index specified. I call this Value
  • Then I specify a FoundValue = where I fetch the CurrentParams and parse the Value key which will return the specified associated value such as My Example Base Name
  • Then I create a FinalString which removes the brackets and then goes to where the [ was originally and inserts the FoundValue
  • Then I update the Current string to be equal to the FinalString
  • And loop again, and if any brackets aren't found it simply breaks out of the loop and returns the newly made CurrentString

5. Create a billboard_main class

Navigate to TycoonStomper/cc/cc.verse

Require the LogicalVisbility, Runtime & StringINaugrable interfaces and provide implementation In the initialize you specify the StringReturnables so you know what the [string]string map looks like image

Create a new public Insantiate method inside billboard_main where you fetch the Owner, set a variable = GetStringParamaters > parse the Text & owner, then update the text with said variable! image

6. Implement the systems wherever necessary

  • For the superclass navigate to TycoonStomper/Purchaseables/superclass.verse

    • Add an editable called BillboardConfig of type billboard_main

    image

    • Under Initialize add BillboardConfig.OnBegin(-1) & BillboardConfig.Initialize(Self)

    image

    • Under InitializeChildren add BillboardConfig.Instantiate() (Initialize children is called when an Item is either Unlocked during the game or was Unlocked by default)

    image

  • For a base navigate to TycoonStomper/cc/cc.verse

    • Under base_setup add a BillboardConfig of type billboard_main

    image

    • Initialize the config

    image

    • Navigate to TycoonStomper/BaseManager.verse
    • Under AwaitBaseClaim call Baes_Setup.BillboardConfig.Instantiate()
    • Create a new check for how many players remain in the base, if its more than the limit Hide the Config.

    image