public WithSSNameTagDecoration(Actor self, WithSSNameTagDecorationInfo info) : base(self, info) { font = Game.Renderer.Fonts[info.Font]; color = info.UsePlayerColor ? self.Owner.Color : info.Color; spawner = self.World.WorldActor.Trait <SpawnSSUnit>(); leader = spawner.TeamLeaders.ContainsKey(self.Owner) ? spawner.TeamLeaders[self.Owner] : null; if (leader != null) { color = leader.Color; } name = self.Owner.PlayerName; if (name.Length > info.MaxLength) { name = name.Substring(0, info.MaxLength); } }
public void ShowFactionDropDown(World world, SpawnSSUnit spawner, DropDownButtonWidget dropdown, Dictionary <string, LobbyFaction> factions) { var player = world.LocalPlayer; Func <string, ScrollItemWidget, ScrollItemWidget> setupItem = (factionId, itemTemplate) => { var item = ScrollItemWidget.Setup(itemTemplate, () => spawner.Classes[player] == factionId, () => { if (spawner.Classes[player] != factionId) { spawner.Classes[player] = factionId; if (spawner.QuickClassChange) { var unit = spawner.Units[player]; if (unit != null && !unit.IsDead) { unit.Kill(unit); } } } }); var faction = factions[factionId]; item.Get <LabelWidget>("LABEL").GetText = () => faction.Name; var flag = item.Get <ImageWidget>("FLAG"); flag.GetImageCollection = () => "flags"; flag.GetImageName = () => factionId; var tooltip = SplitOnFirstToken(faction.Description); item.GetTooltipText = () => tooltip.First; item.GetTooltipDesc = () => tooltip.Second; return(item); }; var options = factions.Where(f => f.Value.Selectable && f.Value.Side != "Random").GroupBy(f => f.Value.Side) .ToDictionary(g => g.Key ?? "", g => g.Select(f => f.Key)); dropdown.ShowDropDown("FACTION_DROPDOWN_TEMPLATE", 154, options, setupItem); }
public SSSpawnProperties(ScriptContext context, Player player) : base(context, player) { this.player = player; spawnSSUnit = player.World.WorldActor.TraitOrDefault <SpawnSSUnit>(); }