Custom Maps & Logic
  • Custom Map Tutorial
    • Custom Map Introduction
    • Your first map
    • Map Navigation
    • Object Selection
    • Object Positioning
    • Object Attributes
    • Shortcuts and Macros
    • Editor Settings
    • Built-in Components Common Errors
    • Map Performance
    • Custom Assets
      • Your first Asset Bundle
      • Asset Bundles in Map Editor
      • Asset Bundles in Game
      • Adding to Asset Bundles
      • Asset Bundle naming
  • Custom Logic Tutorial
    • Custom Logic Introduction
    • Your first script
    • Variables
    • Types
    • Variable Inspector
    • Expressions
    • Conditionals
    • Loops
    • Functions
    • Coroutines
    • Classes
    • Static Classes
    • Components
    • Extensions
    • Cutscenes
    • Static Objects
    • Networking
    • Commenting
  • Reference
    • Static Classes
      • Game
      • Network
      • Map
      • UI
      • Time
      • Convert
      • String
      • Input
      • Math
      • Random
      • Cutscene
      • Camera
      • RoomData
      • PersistentData
      • Json
      • Physics
    • Objects
      • Component
      • Object
      • Character
      • Human
      • Titan
      • Shifter
      • MapObject
      • Transform
      • Player
      • NetworkView
      • Color
      • Vector3
      • Quaternion
      • Dict
      • List
      • Range
      • LineCastHitResult
      • MapTargetable
      • Random
    • Callbacks
      • Main
      • Components
  • Examples
    • Gamemodes
      • Survive
      • Waves
      • Endless
      • Racing
      • Blade PVP
      • Thunderspear PVP
      • Titan Explode
      • Cranked
      • More Examples
    • Components
      • SupplyStation
      • Daylight
      • PointLight
      • Rigidbody
      • NavMeshObstacle
      • Cannon
      • Dummy
      • Wagon
      • Tag
      • KillRegion
      • DamageRegion
      • MovePingPong
      • RacingCheckpointRegion
      • RacingFinishRegion
      • TeleportRegion
      • Animal
      • SignalMover
      • SignalSender
      • More Examples
Powered by GitBook
On this page
  1. Examples
  2. Components

SupplyStation

The SupplyStation component allows humans to refill gas and blades when in a certain region.

component SupplyStation
{
    UnlimitedRefills = true;
    MaxRefills = 0;
    _currentHumanRefill = null;
    _currentHuman = null;

    function Init()
    {
        self._refillsLeft = self.MaxRefills;
        self.MapObject.AddBoxCollider("Region", "Characters", Vector3(0,-2,0), Vector3(14,8,14));
    }

    function OnCollisionStay(other)
    {
        if (other.Type == "Human" && other.IsMine && (self.UnlimitedRefills || self._refillsLeft > 0))
        {
            self._currentHuman = other;
            self._currentHumanRefill = other;
            UI.SetLabelForTime("MiddleCenter", "Press " + Input.GetKeyName("Interaction/Interact") + " to refill." + String.Newline + "Press " + Input.GetKeyName("Interaction/Interact2") + " to change loadout.", 0.1);
        }
    }

    function OnFrame()
    {
        if (self._currentHumanRefill != null)
        {
            if ((self._currentHumanRefill.AutoRefillGas || Input.GetKeyDown("Interaction/Interact")) && self._currentHumanRefill.Refill(true))
            {
                self._currentHumanRefill = null;
                self._refillsLeft = self._refillsLeft - 1;
            }
        }
        if (self._currentHuman != null)
        {
            if (Input.GetKeyDown("Interaction/Interact2"))
            {
                self._currentHuman = null;
                UI.ShowChangeCharacterMenu();
            }
        }
    }

    function OnCollisionExit(other)
    {
        if (other.Type == "Human" && other.IsMine)
        {
            self._currentHuman = null;
            self._currentHumanRefill = null;
        }
    }
}
PreviousComponentsNextDaylight

Last updated 9 months ago