//////////////// protected CustomEntity(CustomEntityConstructor ctor) { var myctor = ctor as CustomEntityConstructor; if (this.OwnerPlayer != null) { this.OwnerPlayerWho = this.OwnerPlayer.whoAmI; this.OwnerPlayerUID = PlayerIdentityHelpers.GetProperUniqueId(this.OwnerPlayer); } else { this.OwnerPlayerWho = -1; this.OwnerPlayerUID = ""; } if (myctor != null) { this.Core = this.CreateCore(myctor); this.Components = this.CreateComponents(myctor); } else { this.Core = this.CreateCoreTemplate(); this.Components = this.CreateComponentsTemplate(); } }
internal void CopyChangesFrom(CustomEntityCore core, IList <CustomEntityComponent> components, Player ownerPlr = null) { this.Core = new CustomEntityCore(core); this.OwnerPlayerWho = ownerPlr != null ? ownerPlr.whoAmI : -1; this.OwnerPlayerUID = ownerPlr != null?PlayerIdentityHelpers.GetProperUniqueId(ownerPlr) : ""; this.Components = components.SafeSelect(c => c.InternalClone()).ToList(); this.ClearComponentCache(); if (!this.IsInitialized) { //throw new HamstarException( "!ModHelpers."+this.GetType().Name+".CopyChangesFrom - Not initialized post-copy." ); throw new HamstarException("Not initialized post-copy."); } }
//////////////// protected override void SetClientDefaults() { this.PlayerIds[Main.myPlayer] = PlayerIdentityHelpers.GetProperUniqueId(Main.LocalPlayer); }