Start business management from menu
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
using GTANetworkAPI;
|
||||
using reallife_gamemode.Model;
|
||||
using reallife_gamemode.Server.Entities;
|
||||
using reallife_gamemode.Server.Extensions;
|
||||
using reallife_gamemode.Server.Util;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@@ -12,6 +13,8 @@ namespace reallife_gamemode.Server.Business
|
||||
public abstract class BusinessBase : IBankAccountOwner
|
||||
{
|
||||
private TextLabel _informationLabel;
|
||||
private Marker _marker;
|
||||
private ColShape _colShape;
|
||||
|
||||
public abstract int Id { get; }
|
||||
public abstract string Name { get; }
|
||||
@@ -35,7 +38,12 @@ namespace reallife_gamemode.Server.Business
|
||||
|
||||
public void Setup()
|
||||
{
|
||||
_informationLabel = NAPI.TextLabel.CreateTextLabel(Name, Position, 20.0f, 1.3f, 0, new Color(255, 255, 255));
|
||||
_informationLabel = NAPI.TextLabel.CreateTextLabel(Name, Position.Add(new Vector3(0, 0, 0.5)), 20.0f, 1.3f, 0, new Color(255, 255, 255));
|
||||
_marker = NAPI.Marker.CreateMarker(MarkerType.VerticalCylinder, Position.Subtract(new Vector3(0, 0, 1.5)), new Vector3(), new Vector3(), 1f, new Color(255, 255, 255), true);
|
||||
|
||||
_colShape = NAPI.ColShape.CreateSphereColShape(Position.Subtract(new Vector3(0, 0, 1.5)), 3f);
|
||||
_colShape.OnEntityEnterColShape += EntityEnterBusinessColShape;
|
||||
_colShape.OnEntityExitColShape += EntityExitBusinessColShape;
|
||||
|
||||
if (GetBankAccount() == null)
|
||||
{
|
||||
@@ -53,10 +61,24 @@ namespace reallife_gamemode.Server.Business
|
||||
}
|
||||
}
|
||||
|
||||
public void Update()
|
||||
private void EntityExitBusinessColShape(ColShape colShape, Client client)
|
||||
{
|
||||
client.TriggerEvent("business_removeHelp", true);
|
||||
}
|
||||
|
||||
private void EntityEnterBusinessColShape(ColShape colShape, Client client)
|
||||
{
|
||||
if (GetOwner() != null && GetOwner().Id == client.GetUser()?.Id && !client.IsInVehicle)
|
||||
{
|
||||
client.TriggerEvent("business_showHelp", Name, (GetBankAccount()?.Balance ?? 0).ToMoneyString());
|
||||
}
|
||||
}
|
||||
|
||||
public void Update(int? money = null)
|
||||
{
|
||||
if (money == null) money = GetBankAccount()?.Balance ?? 0;
|
||||
User owner = GetOwner();
|
||||
string infoText = Name + "\n" + "Besitzer: " + (owner == null ? "Niemand" : owner.Name) + "\nKasse: ~g~" + (GetBankAccount()?.Balance ?? 0) + "$";
|
||||
string infoText = Name + "\n" + "Besitzer: " + (owner == null ? "Niemand" : owner.Name) + "\nKasse: ~g~" + money.ToMoneyString();
|
||||
_informationLabel.Text = infoText;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user