Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/simulation/components/Player.js
Show First 20 Lines • Show All 68 Lines • ▼ Show 20 Lines | Player.prototype.Init = function() | ||||
this.sharedDropsites = false; | this.sharedDropsites = false; | ||||
this.formations = []; | this.formations = []; | ||||
this.startCam = undefined; | this.startCam = undefined; | ||||
this.controlAllUnits = false; | this.controlAllUnits = false; | ||||
this.isAI = false; | this.isAI = false; | ||||
this.cheatsEnabled = false; | this.cheatsEnabled = false; | ||||
this.panelEntities = []; | this.panelEntities = []; | ||||
this.resourceNames = {}; | this.resourceNames = {}; | ||||
this.disabledTemplates = {}; | |||||
this.disabledTechnologies = {}; | |||||
this.spyCostMultiplier = +this.template.SpyCostMultiplier; | this.spyCostMultiplier = +this.template.SpyCostMultiplier; | ||||
this.barterEntities = []; | this.barterEntities = []; | ||||
this.barterMultiplier = { | this.barterMultiplier = { | ||||
"buy": clone(this.template.BarterMultiplier.Buy), | "buy": clone(this.template.BarterMultiplier.Buy), | ||||
"sell": clone(this.template.BarterMultiplier.Sell) | "sell": clone(this.template.BarterMultiplier.Sell) | ||||
}; | }; | ||||
// Initial resources. | // Initial resources. | ||||
▲ Show 20 Lines • Show All 813 Lines • ▼ Show 20 Lines | Player.prototype.TributeResource = function(player, amounts) | ||||
Engine.BroadcastMessage(MT_TributeExchanged, { | Engine.BroadcastMessage(MT_TributeExchanged, { | ||||
"to": player, | "to": player, | ||||
"from": this.playerID, | "from": this.playerID, | ||||
"amounts": amounts | "amounts": amounts | ||||
}); | }); | ||||
}; | }; | ||||
Player.prototype.AddDisabledTemplate = function(template) | |||||
{ | |||||
this.disabledTemplates[template] = true; | |||||
Engine.BroadcastMessage(MT_DisabledTemplatesChanged, { "player": this.playerID }); | |||||
}; | |||||
Player.prototype.RemoveDisabledTemplate = function(template) | |||||
{ | |||||
this.disabledTemplates[template] = false; | |||||
Engine.BroadcastMessage(MT_DisabledTemplatesChanged, { "player": this.playerID }); | |||||
}; | |||||
Player.prototype.SetDisabledTemplates = function(templates) | |||||
{ | |||||
this.disabledTemplates = {}; | |||||
for (let template of templates) | |||||
this.disabledTemplates[template] = true; | |||||
Engine.BroadcastMessage(MT_DisabledTemplatesChanged, { "player": this.playerID }); | |||||
}; | |||||
Player.prototype.GetDisabledTemplates = function() | |||||
{ | |||||
return this.disabledTemplates; | |||||
}; | |||||
Player.prototype.AddDisabledTechnology = function(tech) | |||||
{ | |||||
this.disabledTechnologies[tech] = true; | |||||
Engine.BroadcastMessage(MT_DisabledTechnologiesChanged, { "player": this.playerID }); | |||||
}; | |||||
Player.prototype.RemoveDisabledTechnology = function(tech) | |||||
{ | |||||
this.disabledTechnologies[tech] = false; | |||||
Engine.BroadcastMessage(MT_DisabledTechnologiesChanged, { "player": this.playerID }); | |||||
}; | |||||
Player.prototype.SetDisabledTechnologies = function(techs) | |||||
{ | |||||
this.disabledTechnologies = {}; | |||||
for (let tech of techs) | |||||
this.disabledTechnologies[tech] = true; | |||||
Engine.BroadcastMessage(MT_DisabledTechnologiesChanged, { "player": this.playerID }); | |||||
}; | |||||
Player.prototype.GetDisabledTechnologies = function() | |||||
{ | |||||
return this.disabledTechnologies; | |||||
}; | |||||
Player.prototype.OnGlobalPlayerDefeated = function(msg) | Player.prototype.OnGlobalPlayerDefeated = function(msg) | ||||
{ | { | ||||
let cmpSound = Engine.QueryInterface(this.entity, IID_Sound); | let cmpSound = Engine.QueryInterface(this.entity, IID_Sound); | ||||
if (!cmpSound) | if (!cmpSound) | ||||
return; | return; | ||||
let soundGroup = cmpSound.GetSoundGroup(this.playerID === msg.playerId ? "defeated" : this.IsAlly(msg.playerId) ? "defeated_ally" : this.state === "won" ? "won" : "defeated_enemy"); | let soundGroup = cmpSound.GetSoundGroup(this.playerID === msg.playerId ? "defeated" : this.IsAlly(msg.playerId) ? "defeated_ally" : this.state === "won" ? "won" : "defeated_enemy"); | ||||
if (soundGroup) | if (soundGroup) | ||||
Engine.QueryInterface(SYSTEM_ENTITY, IID_SoundManager).PlaySoundGroupForPlayer(soundGroup, this.playerID); | Engine.QueryInterface(SYSTEM_ENTITY, IID_SoundManager).PlaySoundGroupForPlayer(soundGroup, this.playerID); | ||||
}; | }; | ||||
Engine.RegisterComponentType(IID_Player, "Player", Player); | Engine.RegisterComponentType(IID_Player, "Player", Player); |
Wildfire Games · Phabricator